Change FROM address for Sending Email - VBscript

Posted on 2011-05-04
Last Modified: 2012-05-11

I am using the below sample script which I have found on EE to send emails. I am trying to change the from address in the script, but its not being sent from the FROM address given, its sending the from the same as its connecting to the server, ie: sEmailAddress

Can someone please advise?


Sub SendEmail(sSubject, sEmailText, sEmailAddress, sPassword, sTo, sCCEmailAddress, sAttachment)
    Set oEmail = CreateObject("CDO.Message")

    oEmail.From = ""
    oEmail.To = sTo
    oEmail.CC = sCCEmailAddress
    oEmail.AddAttachment sAttachment
    oEmail.Subject = sSubject
    oEmail.HTMLbody = sEmailText

    sSchema = ""
    oEmail.Configuration.Fields.Item(sSchema & "sendusing") = 2
    oEmail.Configuration.Fields.Item(sSchema & "smtpserver") = ""
    oEmail.Configuration.Fields.Item(sSchema & "smtpserverport") = 465
    oEmail.Configuration.Fields.Item(sSchema & "smtpauthenticate") = 1
    oEmail.Configuration.Fields.Item(sSchema & "sendusername") = sEmailAddress
    oEmail.Configuration.Fields.Item(sSchema & "sendpassword") = sPassword
    oEmail.Configuration.Fields.Item(sSchema & "smtpusessl") = 1
    oEmail.Configuration.Fields.Item(sSchema & "smtpconnectiontimeout") = 60

    Set oEmail = Nothing
End Sub

Open in new window

Question by:charlie324
    LVL 28

    Expert Comment


    oEmail.From = New Net.Mail.MailAddress("")
    LVL 28

    Accepted Solution

    Oops, sorry. I think I gave you .net code.
    Should be something like this:

    oEmail.From = """Test"" <>"

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
    Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now