L
LDMueller
I have Access 2003 and Outlook 2003. I want to email a report to someone as
an attachment, but I also want the email to have voting buttons. I was able
to write the code with help from other snipets I found.
I have everything working except as coded below, I can attach a file, but I
can't attach the report named "rptAnnualRpt".
Note I can attach a report using DoCmd.SendObject, but then I don't know how
to add the voting buttons.
Here's my code...
Sub sbSendMessage(Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objoutlook1 As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add("John Doe")
objOutlookRecip.Type = olTo
Set objOutlookRecip = .Recipients.Add("Jane Doe")
objOutlookRecip.Type = olCC
.Subject = "Annual Report"
.Body = "Attached is your report."
.VotingOptions = "Yes, Report is Accurate;No, Report is Inaccurate"
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
ErrorMsgs:
MsgBox Err.Number, Err.Description
End Sub
Private Sub cmdSend_Click()
Me.sbSendMessage ("C:\Documents and Settings\ldm\My
Documents\Customers.txt")
End Sub
Thanks in advance!
LDMueller
an attachment, but I also want the email to have voting buttons. I was able
to write the code with help from other snipets I found.
I have everything working except as coded below, I can attach a file, but I
can't attach the report named "rptAnnualRpt".
Note I can attach a report using DoCmd.SendObject, but then I don't know how
to add the voting buttons.
Here's my code...
Sub sbSendMessage(Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objoutlook1 As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add("John Doe")
objOutlookRecip.Type = olTo
Set objOutlookRecip = .Recipients.Add("Jane Doe")
objOutlookRecip.Type = olCC
.Subject = "Annual Report"
.Body = "Attached is your report."
.VotingOptions = "Yes, Report is Accurate;No, Report is Inaccurate"
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
ErrorMsgs:
MsgBox Err.Number, Err.Description
End Sub
Private Sub cmdSend_Click()
Me.sbSendMessage ("C:\Documents and Settings\ldm\My
Documents\Customers.txt")
End Sub
Thanks in advance!
LDMueller