Discussion Locked

Excel Macro for emailing

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I'd like to set up a macro to email my current file to several different email addresses. Two questions: #1 - how do I set that up? #2 - is there a way to prevent the message from MS Outlook that says something like "another program is trying to send an email on your behalf, would you like to continue", or something like that? Thanks

1 reply

by bschaettle

This code should be "close"...it's from a script file. For more information, read up on Collaboration Data Objects (CDO).

Set objEmail = CreateObject("CDO.Message")
objEmail.From = "you@yourdomain.com"
objEmail.To = "recipient_1@domain_name.com; recipient_2@domain_name.com; recipient_2@domain_name.com"
objEmail.Subject = "This is the subject line"
objEmail.Textbody = "message body goes here"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "your_mail_server_name"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
Set objEmail = Nothing

This discussion is closed to new replies.