metropia
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.
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
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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
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>"
Also, I believe you meant "web.com"? Or was it web.something.com and you just deleted the "something"?
ASKER
i edited those values.
let me try it again.
thanks!
let me try it again.
thanks!
ASKER
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.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.morrison.com"
'Server port (typically 25)
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.F ields.Upda te
'==End remote SMTP server configuration section==
objMessage.Send
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
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.morrison.com"
'Server port (typically 25)
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.F
'==End remote SMTP server configuration section==
objMessage.Send
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
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!
Thanks!
http://www.blat.net/