Connecting Tech Pros Worldwide Help | Site Map

Using VBA to email w/ attachments

  #1  
Old January 21st, 2006, 07:15 AM
Newbie
 
Join Date: Jan 2006
Posts: 2
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
  #2  
Old September 21st, 2006, 04:41 PM
Newbie
 
Join Date: Sep 2006
Posts: 1

re: Using VBA to email w/ attachments


Quote:
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@jsmcnamara.com
  #3  
Old September 21st, 2006, 10:47 PM
Newbie
 
Join Date: Sep 2006
Posts: 2

re: Using VBA to email w/ attachments


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

http://www.rondebruin.nl/sendmail.htm
  #4  
Old September 21st, 2006, 11:57 PM
Newbie
 
Join Date: Jan 2006
Posts: 2

re: Using VBA to email w/ attachments


Quote:
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@jsmcnamara.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.Application
Set olNewMail = olApp.CreateItem(olMailItem)
With olNewMail
.Display
.Recipients.Add RecipList
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys ("{TAB}")
SendKeys ("^k")
.Subject = Subject1
.Body = Msg & Chr(13) & Chr(13)
.Attachments.Add Path2 + ExpFile
.Attachments.Add Path2 + TsrFile
.Send
End With
Set olNewMail = Nothing
Set olApp = Nothing

Hope this helps!

Frances
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating an Outlook email with multiple file attachments rmarek answers 1 October 6th, 2007 12:40 AM
Thinking of upgrading runtime from Access 97, but which version to get? ARC answers 14 May 14th, 2007 05:35 AM
Is there a simple way to email? jimmy84c@gmail.com answers 6 February 28th, 2006 12:15 AM
Office COM automatisation - calling python from VBA guy lateur answers 12 July 19th, 2005 03:29 AM