Solved In VBS script : use of Hyperlinks with titles in mail body

January 3, 2014 at 04:24:24
Specs: Windows Server 2003
Im using the belwo vbs script to send the mail. But i need to add hyperlinks in the body of mail, Please help with your inputs, thanks..

dim ArgObj, a
Set fso = CreateObject("Scripting.FileSystemObject")
Set ArgObj = WScript.Arguments
a = ArgObj(0)

SMTPServer = "mail.abc.com"
Recipient = "Suhail_Abbas@abc.com"
Cc = "Suhail_Abbas@abc.com"
From = "Suhail_Abbas@abc.com"
Subject = a
Message = "Here Hyperlinks to be added with Captions on it. !"
'attachment = " "

GenericSendmail SMTPserver, From, Recipient, Subject, Message

Sub GenericSendmail (SMTPserver, From, Recipient, Subject, Message)
On Error Resume Next
Set msg = WScript.CreateObject("CDO.Message")
If Err.Number Then 'Problem with CDO.Message
WScript.Echo "Problem with CDO.Message:" & Err.Description
Abort(Err.Number)
End If
msg.From = From
msg.To = Recipient
msg.Cc = Cc
msg.Subject = Subject
msg.TextBody = Message
'msg.AddAttachment attachment
msg.Configuration.Fields ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
msg.Configuration.Fields.Update
If Err.Number Then 'Mail config problem
WScript.Echo "Mail config problem:" & Err.Description
Abort(Err.Number)
End If
msg.Send
If Err.Number Then 'Mail sending failed
WScript.Echo "Mail sending failed:" & Err.Description
Abort(Err.Number)
End If
End Sub

Sub Abort (errNum)
On Error Resume Next
WScript.StdOut.WriteLine "Error #" & errNum
WScript.Quit errNum
End Sub


See More: In VBS script : use of Hyperlinks with titles in mail body

Report •

✔ Best Answer
January 6, 2014 at 15:19:57
Hello. It took me awhile, but I found this:
http://www.paulsadowski.com/wsh/cdo...
which presented the incredibly simple solution (as opposed to MSDN's objectrenderer, which I did not understand a word of...)
Instead of specifying msg.textbody, use msg.HTMLbody
f/e:

msg.HTMLbody=''1st Report''

this is instead of Omessage.textbody, which my simple mailer was using. You may or may not need "http://" prepended, but my test did not*. Note that as per standard HTML, your cosmetic string is preceded by the link-tag itself.
*oops: the http:// IS necessary. my mistake.

message edited by nbrane



#1
January 3, 2014 at 20:24:33
Message = "Here Hyperlinks to be added with Captions on it. !"

Message = "Here Hyperlinks to be added with Captions on it. !: http://www.computing.net/programmin... goodbye!"


Report •

#2
January 6, 2014 at 04:28:25
Thx Nbrane for reply. But it is not working out for me.

I tried giving like below

Message = "Report available below, " & VbCrLf
Message = Message & "1st Report http://report.abc.com/ReportID=1" & VbCrLf
Message = Message & "2nd Report http://report.abc.com/ReportID=2" & VbCrLf
Message = Message & "3rd Report http://report.abc.com/ReportID=3" & VbCrLf
Message = Message & "4th Report http://report.abc.com/ReportID=4" & VbCrLf

I got the output like below :

Report available below,
1st Report http://report.abc.com/ReportID=1
2nd Report http://report.abc.com/ReportID=2
3rd Report http://report.abc.com/ReportID=3
4th Report http://report.abc.com/ReportID=4

My expected output is only Caption with hyperlink,

Report available below,
1st Report
2nd Report
3rd Report
4th Report


Report •

#3
January 6, 2014 at 04:29:44
Please share your inputs on the above request.

Report •

Related Solutions

#4
January 6, 2014 at 15:19:57
✔ Best Answer
Hello. It took me awhile, but I found this:
http://www.paulsadowski.com/wsh/cdo...
which presented the incredibly simple solution (as opposed to MSDN's objectrenderer, which I did not understand a word of...)
Instead of specifying msg.textbody, use msg.HTMLbody
f/e:

msg.HTMLbody=''1st Report''

this is instead of Omessage.textbody, which my simple mailer was using. You may or may not need "http://" prepended, but my test did not*. Note that as per standard HTML, your cosmetic string is preceded by the link-tag itself.
*oops: the http:// IS necessary. my mistake.

message edited by nbrane


Report •

#5
January 7, 2014 at 06:09:39
Thanks a lot.. It works fine :)

Report •

Ask Question