Using VBA to email w/ attachments

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • apa278
    New Member
    • Jan 2006
    • 2

    Using VBA to email w/ attachments

    Hello!

    I'm trying to send out Outlook emails using VBA in Excel. I have a list of email recipients and variablized file names and locations listed out in Excel. I've used the SendMail function before to email out a workbook that's currently open and active, but it looks like that function won't allow any other attachments. What function can I use that will let me attach 2 files to one email?

    I even went straight to the bookstore after work on a Friday night (tonight) because I'm dying to figure this out. But alas, I couldn't find anything helpful.

    I would even be content for somebody to tell me that this isn't even possible... But why the heck wouldn't it be?

    Thanks for reading my post,
    Frances
  • mredge600
    New Member
    • Sep 2006
    • 1

    #2
    Originally posted by apa278
    Hello!

    I'm trying to send out Outlook emails using VBA in Excel. I have a list of email recipients and variablized file names and locations listed out in Excel. I've used the SendMail function before to email out a workbook that's currently open and active, but it looks like that function won't allow any other attachments. What function can I use that will let me attach 2 files to one email?

    I even went straight to the bookstore after work on a Friday night (tonight) because I'm dying to figure this out. But alas, I couldn't find anything helpful.

    I would even be content for somebody to tell me that this isn't even possible... But why the heck wouldn't it be?

    Thanks for reading my post,
    Frances
    Frances, I am looking for the same thing, let me know if you have found out how to do this.
    Thanks Doug
    dpawloske@jsmcn amara.com

    Comment

    • vnaz235
      New Member
      • Sep 2006
      • 2

      #3
      Perhaps, you can find some ideas using the following link:

      http://www.rondebruin. nl/sendmail.htm

      Comment

      • apa278
        New Member
        • Jan 2006
        • 2

        #4
        Originally posted by mredge600
        Frances, I am looking for the same thing, let me know if you have found out how to do this.
        Thanks Doug
        dpawloske@jsmcn amara.com
        Hi Doug,

        Here's the Outlook code that I used. You could just keep adding additional Attachments.Add lines for every attachment you'd like to put in the email.

        The "^k" (equiv to Ctrl+k) is the keyboard shortcut to run the "Check Names" function, which identifies the recipients listed as being in the Global Address List. "Chr(13)" represents hitting Enter. RecipList, Subject1, Msg, Path2, ExpFile, and TsrFile are all variables I defined earlier in the macro.

        Set olApp = New Outlook.Applica tion
        Set olNewMail = olApp.CreateIte m(olMailItem)
        With olNewMail
        .Display
        .Recipients.Add RecipList
        Application.Wai t (Now + TimeValue("0:00 :01"))
        SendKeys ("{TAB}")
        SendKeys ("^k")
        .Subject = Subject1
        .Body = Msg & Chr(13) & Chr(13)
        .Attachments.Ad d Path2 + ExpFile
        .Attachments.Ad d Path2 + TsrFile
        .Send
        End With
        Set olNewMail = Nothing
        Set olApp = Nothing

        Hope this helps!

        Frances

        Comment

        Working...