Okay, I ran a test in Win7 (the same as I did once before, and it works fine). This is on a simple Desktop machine, using my ISP's smtp server. Nothing fancy in the email. At work you'd probably use your company's smtp server, which you can probably see in your outlook setup options - it's usually
smtp.mycompany.com or
mail.mycompany.com.
For your testing, I'd recommend early binding. This makes for easier and more accurate coding since you have access to object methods and properties with intellisense. It will also, incidentally, require to be sure you have the class library you need.
Code:
[COLOR="Navy"]Function[/COLOR] SendEmailCDO()
[COLOR="Navy"]Dim[/COLOR] objMessage [COLOR="Navy"]As[/COLOR] CDO.Message
[COLOR="Navy"]On[/COLOR] [COLOR="Navy"]Error[/COLOR] [COLOR="Navy"]GoTo[/COLOR] ErrHandler:
[COLOR="Navy"]Set[/COLOR] objMessage = [COLOR="Navy"]New[/COLOR] CDO.Message
[COLOR="Navy"]With[/COLOR] objMessage
.Subject = "Test [" & Now & "]"
.From = "somebody [at] emailaddress.net"
.To = "me [at] emailaddress.net"
.TextBody = "This is a Test [" & Now & "]"
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.east.cox.net"
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Configuration.Fields.Update
.send
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
My_Exit:
[COLOR="Navy"]Set[/COLOR] objMessage = [COLOR="Navy"]Nothing[/COLOR]
[COLOR="Navy"]Exit[/COLOR] [COLOR="Navy"]Function[/COLOR]
ErrHandler:
MsgBox Err.Description
[COLOR="Navy"]Resume[/COLOR] My_Exit
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Function[/COLOR]
You want to be sure to reference the CDO library to use this code:
<img alt="image" src="http://northernocean.net/etc/mrexcel/20120415_references.jpg" />
In case anyone is wondering, most ISP's will cut you off if you tried to use something like this for sending spam from home (i.e., sending a *lot* of email) - that's why they require you to go through their smtp server when sending email from home. But it will work even from home if you are sending out a small number of emails from your machine -- I think this means something like 25 per day, but I'm not really sure.