PDA

View Full Version : Can someone see what is going wrong??



Arcadia
04-07-2014, 03:43 AM
I'm trying to compose a mailt with the form information as attachment like you can see in the code below but i keep getting this error, can someone see what i'm doing wrong? :crying:


11523

With the following highlited in yellow:

Set olMail =



Private Sub Command19_Click()

Set fso = CreateObject("Scripting.FileSystemObject")
Set olObj = GetObject(, "Outlook.Application")
Set olMail = olObj.CreateItem(olMailItem)




olMail.Subject = "Training"
olMail.Importance = "2"
olMail.To = ""
olMail.CC = ""
olMail.BCC = ""
olMail.HTMLBody = "Here comes the body"
Email_Subject = "Subject"
olMail.Display



On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
.CC = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body

.Send
'acFormatpdf will export the result of query into pdf format and will add the pdf as attachment
DoCmd.SendObject acSendForm, “sales_detail”, acFormatPDF, mailto, ccto, bccto, mailsub, emailmsg, True

End Sub

SamT
04-07-2014, 06:06 AM
IF it ain't in the yellow, look before the yellow.


Is that comma necessary?


Hint. Always put "Option Explicit" at the top of your code modules. In the VBA editor (the VBA), use the Options Menus to require declarations.