> Thanks, but not quite what I'm looking for. This allows me to send TO
the same person each time. In my scenario, each record has it's own
email address (one property, name, phone, email address, is on the
screen at a time). I need to be able to send to various email
addresses (whichever one is on the screen at the time) with a push of a
button.
I can declare my subject line. I can even declare a few lines of text.
How can I declare the desired email address based on the contact
person's email addy?
The routine below is in a database where each record has a subform datasheet
with a list of associated email addresses. Users can enter a comment after
each email address if desired like this:
so*********@somedomain.com # this is Joe's home email address
double-clicking on the email address in the datasheet opens and addresses an
email to that address. With a little code you can extend this to do other
things. A good site for reference is
http://www.slipstick.com/
Private Sub E_mail_Addresses_DblClick(Cancel As Integer)
'Required reference: Microsoft Outlook 11.0 Object Library
On Error GoTo HandleErr
Dim strEmail As String
Dim olapp As Outlook.Application
Dim olmi As Outlook.MailItem
Dim j As String
Set olapp = GetObject(, "Outlook.Application")
strEmail = Me![E-mail Addresses]
j = InStr(1, strEmail, "#", 1)
If j Then strEmail = Trim$(Left(strEmail, j - 1))
Set olmi = olapp.CreateItem(olMailItem)
olmi.Recipients.Add strEmail
olmi.display
Exit_Here:
On Error Resume Next
Set olmi = Nothing
Set olapp = Nothing
Exit Sub
HandleErr:
Select Case Err.Number
Case 94 'Invalid use of Null
'(when double clicking on blank field)
Case 287
Case 429
'if the mail item we are creating is sent, it will not leave
'the outbox unless Outlook is open. To make sure messages
'are sent immedaitely, outlook is opened here if it is
'not already open.
Call Shell(modOffice.GetOutlookPath)
Set olapp = New Outlook.Application
Resume Next
Case Else
modHandler.LogErr "frm0Email", "E_mail_Addresses_DblClick"
End Select
Resume Exit_Here
End Sub