Connecting Tech Pros Worldwide Help | Site Map

Using VBA to email w/ attachments

 
LinkBack Thread Tools Search this Thread
  #1  
Old January 21st, 2006, 06:15 AM
Newbie
 
Join Date: Jan 2006
Posts: 2
Default 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
Reply
  #2  
Old September 21st, 2006, 03:41 PM
Newbie
 
Join Date: Sep 2006
Posts: 1
Default

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
Reply
  #3  
Old September 21st, 2006, 09:47 PM
Newbie
 
Join Date: Sep 2006
Posts: 2
Default

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

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

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
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.