PDA

View Full Version : SMTP emailing



sconly
08-10-2010, 09:01 AM
Before anyone says, I have done a search on this forum.

I was wondering if anyone has any (vba) code example for creating/sending an email using a SMTP server from Excel?

is CDO the only way? I only ask because part of the cdo code i've found has the following in it and when i put any of the web addresses into my address bar all i get back is an error page.


Dim Flds As Variant
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
= "Fill in your SMTP server here"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With

Thanks!

slamet Harto
08-10-2010, 01:59 PM
I use this part of code
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "XX.XXX.XX.XXX" '"Fill in your SMTP server here" or use IP Address
.Item("http://schemas.microsoft.com/cdo/configuration/senduserreplyemailaddress") = """Another"" <domain\username>"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "domain\username"
.Item "http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
.Update
End With

Bob Phillips
08-10-2010, 02:05 PM
Ron has a lot of info at http://www.rondebruin.nl/cdo.htm