RE: Email Code
- From: Doug_C <DougC@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 19 Sep 2006 06:40:02 -0700
This is code I use in my database. Just modify the fields to your needs.
Shouldn't have any problems, works very well for me.
Private Sub Command51_Click()
On Error GoTo eh
Dim SendTo As String, MySubject As String, MyMessage As String
SendTo = "whatever email address@xxxxxxxxxxxx"
MySubject = "TEST"
MyMessage = TEST
DoCmd.SendObject acSendNoObject, , , SendTo, , , MySubject, MyMessage, True
eh:
If Err.Number = 2501 Then
MsgBox "This email message has not been sent. Message has been
cancelled."
End If
End Sub
"CAM" wrote:
Hello,.
I am trying to figure out what is wrong with my code (see below). When I
press the email button I get two New message from outlook. The first show
the actual email message and then a second new message appearing, but is
blank. What am I doing wrong. I should only get the e-mail with message
displaying not a blank. Thank you in advance.
Private Sub cmdEmail_Click()
On Error GoTo Err_cmdEmail_Click
'email notification response
Dim email As String
Dim ref As String
Dim EmailNotification As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
email = GroupMemberEmail
EmailNotification = Notification
ref = "Update Master Project Database"
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
..To = email
..Subject = ref
..body = EmailNotification
..Display
End With
Exit_cmdEmail_Click:
Exit Sub
Err_cmdEmail_Click:
MsgBox Err.Description
Resume Exit_cmdEmail_Click
End Sub
- Follow-Ups:
- Re: Email Code
- From: CAM
- Re: Email Code
- References:
- Email Code
- From: CAM
- Email Code
- Prev by Date: Continous Form(s) Issue
- Next by Date: Re: Help with Microsoft help on linking Access to Outlook
- Previous by thread: Email Code
- Next by thread: Re: Email Code
- Index(es):