Consulting

Results 1 to 3 of 3

Thread: SMTP emailing

  1. #1
    VBAX Regular
    Joined
    Apr 2010
    Posts
    32
    Location

    SMTP emailing

    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!

  2. #2
    VBAX Tutor
    Joined
    Sep 2007
    Posts
    265
    Location
    I use this part of code
    [vba]Set iConf = CreateObject("CDO.Configuration")
    iConf.Load -1 ' CDO Source Defaults
    Set Flds = iConf.Fields
    With Flds
    .Item("http://schemas.microsoft.com/cdo/con...tion/sendusing") = 2
    .Item("http://schemas.microsoft.com/cdo/con...ion/smtpserver") = "XX.XXX.XX.XXX" '"Fill in your SMTP server here" or use IP Address
    .Item("http://schemas.microsoft.com/cdo/con...lyemailaddress") = """Another"" <domain\username>"
    .Item("http://schemas.microsoft.com/cdo/con...smtpserverport") = 25
    .Item("http://schemas.microsoft.com/cdo/con...tpauthenticate") = 1
    .Item("http://schemas.microsoft.com/cdo/con...n/sendusername") = "domain\username"
    .Item "http://schemas.microsoft.com/cdo/con...n/sendpassword") = "password"
    .Update
    End With
    [/vba]

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Ron has a lot of info at http://www.rondebruin.nl/cdo.htm
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •