attachment by using sendobject

mchoud

Registered User.
Local time
Today, 00:30
Joined
Jun 3, 2003
Messages
25
How do i can send email using send object and including an attachment for it.

This is my module
DoCmd.SendObject , , , "&GetEmail(strToUserName)&", , , "Subject: Document Reminder - " & " You have a waiting document " & [strDocNum] & ", need to be " & [strAction] & ".", "You have a waiting document " & [strDocNum] & ", need to be " & [strAction] & ".", False, Data.htm

Thanks
Mchoud
 
Here is some code I use to output a report in Snapshot format and then attach it to an e-mail

DoCmd.OpenForm "Please_Wait_Message_(E-Mail)", acNormal, "", "", acReadOnly, acNormal
DoCmd.RepaintObject acForm, "Please_Wait_Message_(E-Mail)"
DoCmd.SetWarnings False

DoCmd.OutputTo acReport, "Devolution_Comparison_Report", "SnapshotFormat(*.snp)", "G:\E&S\Energy\em\Access_Reports\Devolution_Report.snp", False, ""

Set EmailApp = CreateObject("Outlook.Application")
Set NameSpace = EmailApp.GetNamespace("MAPI")
Set EmailSend = EmailApp.CreateItem(0)

EmailSend.To = DLookup("[E-Mail_Address_To]", "Report_Config", "[Lookup_Id]= '" & Me.Criteria_Selection & "'") ' Put email address here
EmailSend.Subject = "Devolution Report: " & Me.Criteria_Selection
EmailSend.Body = "Dear All," & Chr(13) & Chr(13) & "With regard to the Electricity Devolution Pilot Study for the Stopford Building, Please find attached the cost & consumption figures to date," & Chr(13) & "for the " & IIf(Me.Criteria_Selection = "Resource Centre - Biological Science", "Biological Resource Centre", "Faculty of Medicine") & " within the building." & Chr(13) & Chr(13) & "Yours Sincerely" & Chr(13) & "Kevin Corless" & Chr(13) & Chr(13) & Chr(13) & "If you have problems viewing the attached file please install the viewer software attached, if you continue to have problems please contact, Geoff Codd on 57003" & Chr(13) & Chr(13)
EmailSend.Attachments.Add "G:\E&S\Energy\em\Access_Reports\Devolution_Report.snp" ' Change this to match your path
EmailSend.Attachments.Add "G:\E&S\Energy\em\Data\Snapshot_Viewer.zip" ' Change this to match your path
EmailSend.Display ' Remove this line if you don't want to see email

Set EmailApp = Nothing
Set NameSpace = Nothing
Set EmailSend = Nothing

DoCmd.SetWarnings True
DoCmd.Close acForm, "Please_Wait_Message_(E-Mail)"

I hope it helps
Thanks
Geoff
 
Closed

Hi All

Thanks very much about all of the information.

I have got successfull trick to sending email from Access as per the above article refference.

Thanks once again.
mchoud
 
Attach Current dB object

I think this is a simple one....I've added this code to my dB to get around that ever-frustrating "An application is trying to send..." error. It works great! However, I'd like to attach a table to the e-mail rather than an external file. I've tried everything I can think of, and I'm sure it's something simple. Anyone care to provide the "Doh" for me? (I'll take care of the slap on the forehead!)
:D
I tried replacing the file path with Me.test [test] "test".....you get the picture.

Thanks in advance for any help offered!

P.S.
here's my current code that works

Dim iBP
With mail
.From = "<address>"
.To = "<address>"
.CC = "<address>"
.Subject = "test"
.TextBody = "test"
Set iBP = mail.AddAttachment("C:\Documents and Settings\My Documents\email test.txt")
.Send
End With
 
Last edited:
Hi geoffcodd,

Just to say thanks for posting your code - it helped me a lot. :)

Cheers,
Mike
 

Users who are viewing this thread

Back
Top Bottom