+ Post New Thread
Results 1 to 4 of 4
How do you do....it? Thread, Sending e-mail via vbs and using authentication in Technical; Dear all, I have been using a script for sometime now which was sending e-mails to us via our own ...
  1. #1
    FatBoy's Avatar
    Join Date
    Oct 2007
    Location
    Kent, UK
    Posts
    251
    Thank Post
    55
    Thanked 20 Times in 16 Posts
    Rep Power
    17

    Sending e-mail via vbs and using authentication

    Dear all,

    I have been using a script for sometime now which was sending e-mails to us via our own exchange server and our exchange didn't require authentication. We have just moved our exchange users over to a centralised 2010 exchange cluster at head office and they do require authentication to send mails from the server. I was using this script to send the mails. My question is would anyone know how to send a username and password with this e-mail request so the exchange server accepts the mail and sends it?

    Set objEmail = CreateObject("CDO.Message")
    objEmail.From = "admin1@fabrikam.com"
    objEmail.To = "admin2@fabrikam.com"
    objEmail.Subject = "Server down"
    objEmail.Textbody = "Server1 is no longer accessible over the network."
    objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
    "smarthost"
    objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    objEmail.Configuration.Fields.Update
    objEmail.Send

    Thanks
    FB
    Last edited by FatBoy; 23rd April 2012 at 02:39 PM.

  2. #2


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,014
    Thank Post
    230
    Thanked 2,696 Times in 1,991 Posts
    Rep Power
    791
    I think this should do it...

    Code:
    Const schema   = "http://schemas.microsoft.com/cdo/configuration/"
    Const cdoBasic = 1
    Const cdoSendUsingPort = 2
    Dim oMsg, oConf
    
    ' E-mail Properties
    Set oMsg      = CreateObject("CDO.Message")
    oMsg.From     = "from@example.net"
    oMsg.To       = "to@example.com"
    oMsg.Subject  = "Subject goes here"
    oMsg.TextBody = "Body text goes here"
    
    ' SMTP server configuration and authentication info
    Set oConf = oMsg.Configuration
    oConf.Fields(schema & "smtpserver")       = "smtp.example.net"
    oConf.Fields(schema & "smtpserverport")   = 25
    oConf.Fields(schema & "sendusing")        = cdoSendUsingPort
    oConf.Fields(schema & "smtpauthenticate") = cdoBasic
    oConf.Fields(schema & "smtpusessl")       = False
    oConf.Fields(schema & "sendusername")     = "from@example.net"
    oConf.Fields(schema & "sendpassword")     = "password"
    oConf.Fields.Update
    
    oMsg.Send

  3. #3
    FatBoy's Avatar
    Join Date
    Oct 2007
    Location
    Kent, UK
    Posts
    251
    Thank Post
    55
    Thanked 20 Times in 16 Posts
    Rep Power
    17
    Thanks for this Arthur, things have got really busy here so I'll look into this asap cheers

  4. #4
    FatBoy's Avatar
    Join Date
    Oct 2007
    Location
    Kent, UK
    Posts
    251
    Thank Post
    55
    Thanked 20 Times in 16 Posts
    Rep Power
    17
    Hi Arthur,

    I'm still getting the "The server rejected the sender address. The server response was: 530.5.7.1 Client was not authenticated"
    For the username field I tried the below format, also domain\username, FQDN and just the username on its own!

    oConf.Fields(schema & "sendusername") = "from@example.net"
    oConf.Fields(schema & "sendpassword") = "password"

    Any ideas?
    Thanks
    FB

SHARE:
+ Post New Thread

Similar Threads

  1. WSUS How to install and use????
    By ipconfig/HELP in forum Windows
    Replies: 33
    Last Post: 1st February 2011, 01:27 PM
  2. [SCCM 2007] Deploying Win7 via Advertised programs and using USMT
    By msnriggs in forum O/S Deployment
    Replies: 0
    Last Post: 20th January 2010, 05:14 AM
  3. Replies: 5
    Last Post: 10th February 2009, 05:33 PM
  4. Strong passwords: How to create and use them
    By FN-GM in forum General Chat
    Replies: 0
    Last Post: 15th August 2007, 11:17 AM
  5. Virtual PC and using DHCP
    By Kyle in forum Thin Client and Virtual Machines
    Replies: 2
    Last Post: 7th March 2007, 11:46 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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