Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Outlook, attachments question

Status
Not open for further replies.

newboy18

MIS
Apr 11, 2003
45
GB
Please help, I have 2 questions.
1/. I want my routine to send all .doc files in a folder to a contact but how, the Attachments.Add will not allow me to put “c:\docsemail\*.doc
2/. I want to start Outlook before running this sub routine because it is part of a loop, it will be very slow if I open Outlook for every email. I tried to move the fist 2 lines to the main routine but the sub routine would then fail at the “Set olMail = olApp.CreateItem(olMailItem” line.

Sub EmailDoc()
Dim olApp As Outlook.Application
Set olApp = New Outlook.Application
Dim olMail As MailItem
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = "Smith, John"
.Subject = "New documents”
.Attachments.Add "c:\docsemail\test.txt"
.Attachments.Add "c:\docsemail\test2.txt"
.Send
End With
Set olMail = Nothing
olApp.Quit
Set olApp = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top