Link to home
Start Free TrialLog in
Avatar of metropia
metropiaFlag for United States of America

asked on

send email using vbscript

hello I would like to send an email with an html link in the body using a visual basic script that gets executed by a scheduled task.

I am using the script attached on the code screen, but I keep getting an error that reads:

CDO.Message.1 error '80040220' The "SendUsing" configuration value is invalid.



Set objMessage = CreateObject("CDO.Message") 

objMessage.Subject = "Daily Status Report" 
objMessage.From = "generic@company.com" 
objMessage.To = "distributionlist@company.com"

objMessage.HTMLBody = "<p>Good Morning! This is an automated message sent every morning at 4:30 AM.</p>" 

objMessage.CreateMHTMLBody "http://company.com:8080/do/getCrystalReport?reportId=216&reportFormat=PDF"

objMessage.Send

Open in new window

Avatar of wwwb0n3zcom
wwwb0n3zcom
Flag of United States of America image

I would suggest using Blat instead as it's much easier. I have used it before in the past for automation. Take a look at thier example page.

http://www.blat.net/



ASKER CERTIFIED SOLUTION
Avatar of prashanthd
prashanthd
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of metropia

ASKER

I am having problems formatting the property objMessage.CreateMHTMLBody
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Daily Shipping Status Report - North Branch."
objMessage.From = "@.com"
objMessage.To = "@.com"
objMessage.HTMLBody = "<p>Good Morning! This is an automated message sent every morning at 4:30 AM.</p>" 
objMessage.CreateMHTMLBody "<a href="http://web..com:8080/do/getCrystalReport?reportId=216&reportFormat=PDF">" & "Daily Shipping Status</a>"

'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.joplin.com"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

Open in new window

Line 6 needs a pair of double-quotes [""] on the embedded double-quotes.
objMessage.CreateMHTMLBody "<a href=""http://web..com:8080/do/getCrystalReport?reportId=216&reportFormat=PDF"">" & "Daily Shipping Status</a>"

Open in new window

Also, I believe you meant "web.com"?  Or was it web.something.com and you just deleted the "something"?
i edited those values.

let me try it again.

thanks!
I got a syntax error pointing to that same line :(


dim objMessage
dim strMsg

Set objMessage = CreateObject("CDO.Message")

objMessage.Subject = "Daily Shipping Status Report."
objMessage.From = "reports@"
objMessage.To = "@.com"


objMessage.HTMLBody = "<p>Good Morning! This is an automated message sent every morning at 4:30 AM.</p>"
objMessage.CreateMHTMLBody "<a href=""http://web.foo.com:8080/do/getCrystalReport?reportId=216&reportFormat=PDF"">" & "Daily Shipping Status</a>"



'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.morrison.com"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am accepting my comment as part of the solution because that was the last workaround, in order to make the code provided by prashanthd.

Thanks!