+ Reply to Thread
Results 1 to 5 of 5

Macro for emailing attachments through Outlook

  1. #1
    Registered User
    Join Date
    06-29-2007
    Posts
    57

    Macro for emailing attachments through Outlook

    I am new to marco's, and this is the first one I have ever tried to build. I need a macro, that when I click a button, it opens a new email and attaches a specified file to it. I have gotten the code to open a new outlook message window, but can't get it to attach a file, nor fill out the subject, and body area. Here is my code. Can someone tell me what it is that I am doing wrong?

    Private Sub CommandButton2_Click()

    Dim ol As Outlook.Application
    Set ol = CreateObject("Outlook.Application")

    Dim newMessage As Outlook.MailItem
    Set newMessage = ol.CreateItem(olMailItem)
    newMessage.Display

    With EmailItem
    .Subject = "Marketing Material"
    .Body = "Attached is the information you requested. "
    .Importance = olImportanceNormal
    .Attachments.Add "C:\Documents and Settings\jtewell\My Documents\authorization letter.pdf"

    End With
    End Sub

    Thanks

  2. #2
    Forum Contributor
    Join Date
    11-23-2005
    Location
    Perth, Australia
    Posts
    218

    Macro for emailing attachments through Outlook

    Hi jat82nd

    For future reference please use code tages for any code you show(as per forum rules)

    For your question i would suggest having a look at the below site:
    http://www.rondebruin.nl/sendmail.htm

    Let me know how you go!

  3. #3
    Registered User
    Join Date
    06-29-2007
    Posts
    57
    Thanks I will take a look at it... how do I do code tages?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Jat82nd,

    There's a little more to it than what you have. I use this macro quite often. This one is structured to do emailings from a list on a worksheet. It uses columns "A - D" for the Recipient, Subject, Message, and a File Attachment. The comments explain what is happening. I prefer to use late binding to avoid the user not having a VBA library reference added in.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    06-29-2007
    Posts
    57
    Thanks... that worked great. Is there a way to add a formula to it that would look at lets say, cell A1, then do a Vlookup function on columns A & B, then attach the files in that row?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1