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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I send e-mail from Outlook only if it's in certain directory

Status
Not open for further replies.
Jan 8, 2002
1
US
I'm brand new to VBA and have taken on probably more than I can chew.

I'm looking to create VBA code to have Outlook 2000 send an e-mail only when an e-mail arrives in a certain folder. My folder is currently Inbox/Quarantine, but could/should be Deleted Items. I've found code to send the mail, but not to "watch" the Quarantine folder for incoming mail. Please see code I already have below.

Thanks,
haystack47

Sub EmailFromOutlookInExcel() 'macro name
Set myOlApp = CreateObject("Outlook.Application") 'opens Outlook
Set MailItem = myOlApp.CreateItem(olMailItem) ' opens new email
Set myRecipient = MailItem.Recipients.Add("recipient@company.com")'inserts recipient's email address
MailItem.Subject = "Subject of message goes here" 'subject of the email
Set myAttachments = MailItem.Attachments.Add("C:\foldername\filename")'Path To Attachments
'Repeat this line if there are more Atta
' chments
MailItem.Send'sends the email
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top