E-mail Attachment

Haynesey

Registered User.
Local time
Today, 12:35
Joined
Dec 19, 2001
Messages
190
Hi,

I use the following code to send an e-mail to users which creates an RTF file from a report. This works great but now I want to attach a separate word document questionnaire to the e-mail too. Is this possible?

DoCmd.SendObject acReport, stDocName2, "RichTextFormat(*.rtf)", EmailAddress, , , SubjectLine, _
"Please see attached document.", False

Thanks in advance

Lee
 
Lee,
Try this.
Code:
Dim olkapp As Outlook.Application
Dim olknamespace As Outlook.NameSpace
Dim objmailitem As Outlook.MailItem
Dim CN As String

CN = "C:\My Report.snp" 

DoCmd.OutputTo acOutputReport, "rptName", acFormatSNP, CN ' create your report

Set olkapp = New Outlook.Application
Set olknamespace = GetNamespace("MAPI")
Set objmailitem = olkapp.CreateItem(olMailItem)

With objmailitem
.To = "You Recipient"
.Subject = "Subject Details"
.Body = "Your body text"
.Attachments.Add CN 'attach your report
.Attachments.Add "C:\Your Doc Name" 'attach your other file
.Send
End With
Set olkapp = Nothing
Set olknamespace = Nothing
Set objmailitem = Nothing
Set dbs = Nothing
Kill CN 'delete the report created

ErrProc:
            MsgBox Err.Description
            Exit Sub
End Sub
 

Users who are viewing this thread

Back
Top Bottom