LJShepherd
asked on
Send e-mail with attachments from Access
Hi,
I want to send an e-mail from Access with attachments using a control button, but have the ability to edit the message before it goes.
I am using the code below to send, but cannot fathom out a way of adding code in to edit the message prior to sending.
Can you help please?
Thanks
Private Sub Command35_Click()
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Appl ication")
Set MailOutLook = appOutLook.CreateItem(olMa ilItem)
strAttach = "c:\Databases\pricer\" & Me.Ref & ".pdf"
With MailOutLook
.BodyFormat = olFormatHTML
.To = Me.e_mail
''.cc = ""
''.bcc = ""
.Subject = "Quotation Ref" & Me.Ref
.HTMLBody = "Please find attached your quotation"
.Attachments.Add strAttach
.Send
End With
End Sub
I want to send an e-mail from Access with attachments using a control button, but have the ability to edit the message before it goes.
I am using the code below to send, but cannot fathom out a way of adding code in to edit the message prior to sending.
Can you help please?
Thanks
Private Sub Command35_Click()
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Appl
Set MailOutLook = appOutLook.CreateItem(olMa
strAttach = "c:\Databases\pricer\" & Me.Ref & ".pdf"
With MailOutLook
.BodyFormat = olFormatHTML
.To = Me.e_mail
''.cc = ""
''.bcc = ""
.Subject = "Quotation Ref" & Me.Ref
.HTMLBody = "Please find attached your quotation"
.Attachments.Add strAttach
.Send
End With
End Sub
ASKER
Hi Jim,
I have added the .Visible, but I then get a RunTime error 438 message saying "Object doesn't support this property or method"
Thanks
Les
I have added the .Visible, but I then get a RunTime error 438 message saying "Object doesn't support this property or method"
Thanks
Les
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here's the code that I use for linking up with Outlook as a procedure:
With a little additional coding, the attachment could be made optional.
Tom
Sub SendMailOutlook(Recipient, Subject, TextBody, stAttachment)
'Create an Outlook object
Dim Outlook As New Outlook.Application
Set Outlook = CreateObject("Outlook.Application")
'Create e new message
Dim Message As Outlook.MailItem
Set Message = Outlook.CreateItem(olMailItem)
With Message
.Subject = Subject
.HTMLBody = TextBody
.To = Recipient
.Attachments.Add (stAttachment)
.Display
End With
End Sub
With a little additional coding, the attachment could be made optional.
Tom
ASKER
Thanks Jim, it worked perfectly.
Much appreciated.
Les
Much appreciated.
Les
You also may need to do:
.Visible = True
so Outlook Displays.
Jim.