Is it possible to send HTML emails with Macro Scheduler ?
Moderators: Dorian (MJT support), JRL
-
- Newbie
- Posts: 6
- Joined: Tue Feb 08, 2005 1:22 pm
Is it possible to send HTML emails with Macro Scheduler ?
Hi !
I'm a new user. I send emails with Macro Scheduler using an smtp server.
I want to import html code and images in these emails, for the recipients to get a nice message.
Is it possible to do that please ? And how ?
Thanks for your answer
Virginie
I'm a new user. I send emails with Macro Scheduler using an smtp server.
I want to import html code and images in these emails, for the recipients to get a nice message.
Is it possible to do that please ? And how ?
Thanks for your answer
Virginie
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
I haven't tried it, but I don't see why not.
Just write the message section using HTML code like this as a variable and include that variable as the %body% portion of the SMTPSendMail> command.
The format that is seen by the recipient will be a function of the ability of their email client.
Just write the message section using HTML code like this as a variable and include that variable as the %body% portion of the SMTPSendMail> command.
The format that is seen by the recipient will be a function of the ability of their email client.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
-
- Newbie
- Posts: 6
- Joined: Tue Feb 08, 2005 1:22 pm
Hum.. not sure that's all.
I have tried this :
Let>body=Hello, visit my web site :click here !
SMTPSendMail>recipients,server,me,myname,subject,body,
and received the message in different email clients.
Here is the result :
Hello, visit my web site :click here !
I think there is something to specify to send HTML messages, for the email client to translate (if it's possible with Macro Scheduler).
I have tried this :
Let>body=Hello, visit my web site :click here !
SMTPSendMail>recipients,server,me,myname,subject,body,
and received the message in different email clients.
Here is the result :
Hello, visit my web site :click here !
I think there is something to specify to send HTML messages, for the email client to translate (if it's possible with Macro Scheduler).
Some email clients notice the HTML and render it accordingly. Pocomail works. But others require a header "Content-type: text/html" to be attached to the message. At present the SMTPSendMail command does not allow you to add custom headers.
But, as always there is an alternative solution. Use Microsoft's CDO COM message class. The following will work in Windows 2000, XP and above. For earlier versions of Windows you should be able to download CDO from microsoft.com.
VBSTART
'Uses Microsoft CDO Message COM class in Win2k,XP & above. See:
'http://msdn.microsoft.com/library/en-us ... erface.asp
Function SendEmail(toaddr,fromaddr,subject,body,html)
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
'change your mail server on the next line
.Item(sch & "smtpserver") = "mail.server.com"
.update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = fromaddr
.To = toaddr
.Subject = subject
if html = 1 then
.HTMLBody = body
else
.TextBody = body
end if
'you can create html body from a web page:
'.CreateHTMLBody "http://blablabla.com/bla.htm"
'you can add attachments:
'.AddAttachment ""
'see URL at top for more options
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
End Function
VBEND
Let>body=Hello, visit my web site :click here !
VBEval>SendEmail("[email protected]","[email protected]","Test html","%body%",1),res As you can see this will send an HTML message if you set html - the last parameter of the function - to 1.
Enjoy
But, as always there is an alternative solution. Use Microsoft's CDO COM message class. The following will work in Windows 2000, XP and above. For earlier versions of Windows you should be able to download CDO from microsoft.com.
VBSTART
'Uses Microsoft CDO Message COM class in Win2k,XP & above. See:
'http://msdn.microsoft.com/library/en-us ... erface.asp
Function SendEmail(toaddr,fromaddr,subject,body,html)
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
'change your mail server on the next line
.Item(sch & "smtpserver") = "mail.server.com"
.update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = fromaddr
.To = toaddr
.Subject = subject
if html = 1 then
.HTMLBody = body
else
.TextBody = body
end if
'you can create html body from a web page:
'.CreateHTMLBody "http://blablabla.com/bla.htm"
'you can add attachments:
'.AddAttachment ""
'see URL at top for more options
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
End Function
VBEND
Let>body=Hello, visit my web site :click here !
VBEval>SendEmail("[email protected]","[email protected]","Test html","%body%",1),res As you can see this will send an HTML message if you set html - the last parameter of the function - to 1.
Enjoy
Last edited by support on Wed Feb 09, 2005 3:27 pm, edited 1 time in total.
MJT Net Support
[email protected]
[email protected]
-
- Newbie
- Posts: 6
- Joined: Tue Feb 08, 2005 1:22 pm
Hi Support,
Thanks for posting the code above, I have it working fine here on XP.
The link you posted in your code though...
http://msdn.microsoft.com/library/en-us ... erface.asp
...no longer works. I checked the Microsoft Developer Network site and found the following:
Exchange Server 2003
The Message COM Class
http://msdn2.microsoft.com/en-us/library/ms526958.aspx
Is that the same page? Or if you know it, can you please post the new link?
Thanks and take care
Thanks for posting the code above, I have it working fine here on XP.
The link you posted in your code though...
http://msdn.microsoft.com/library/en-us ... erface.asp
...no longer works. I checked the Microsoft Developer Network site and found the following:
Exchange Server 2003
The Message COM Class
http://msdn2.microsoft.com/en-us/library/ms526958.aspx
Is that the same page? Or if you know it, can you please post the new link?
Thanks and take care
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
interested in update
trying out this code and get
Microsoft VBScript runtime error: 450
Wrong number of arguments or invalid property assignment: 'SendEmail'
Line2, Column 0
Microsoft VBScript runtime error: 450
Wrong number of arguments or invalid property assignment: 'SendEmail'
Line2, Column 0