?
Solved

Change FROM address for Sending Email - VBscript

Posted on 2011-05-04
2
Medium Priority
?
503 Views
Last Modified: 2012-05-11
Hello,

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?
Thanks

 

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

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

    sSchema = "http://schemas.microsoft.com/cdo/configuration/"
    oEmail.Configuration.Fields.Item(sSchema & "sendusing") = 2
    oEmail.Configuration.Fields.Item(sSchema & "smtpserver") = "smtp.test.com"
    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
    oEmail.Configuration.Fields.Update
    oEmail.Send

    Set oEmail = Nothing
End Sub

Open in new window

0
Comment
Question by:charlie324
  • 2
2 Comments
 
LVL 29

Expert Comment

by:sammySeltzer
ID: 35690280
Try:

oEmail.From = New Net.Mail.MailAddress("test@test.com")
0
 
LVL 29

Accepted Solution

by:
sammySeltzer earned 2000 total points
ID: 35690305
Oops, sorry. I think I gave you .net code.
Should be something like this:

oEmail.From = """Test"" <test@test.com>"
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

850 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