Solved

Send e-mail with attachments from Access

Posted on 2013-11-13
5
738 Views
Last Modified: 2013-11-13
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.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
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
0
Comment
Question by:LJShepherd
  • 2
  • 2
5 Comments
 
LVL 57
ID: 39644275
You don't want the .Send

You also may need to do:

.Visible = True

so Outlook Displays.

Jim.
0
 

Author Comment

by:LJShepherd
ID: 39644290
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
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 39644291
I just double checked, and to make it visible, you need to do:

            .Display

Which is a method of the mail object, not a property.

.Visible would be a property of Outlook itself and will probably work as well, but use the mail objects display method.  That will make the mail object visible for sure.

Jim.
0
 
LVL 6

Expert Comment

by:ButlerTechnology
ID: 39644295
Here's the code that I use for linking up with Outlook as a procedure:
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

Open in new window


With a little additional coding, the attachment could be made optional.

Tom
0
 

Author Closing Comment

by:LJShepherd
ID: 39644299
Thanks Jim, it worked perfectly.

Much appreciated.

Les
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now