Is it possible to send HTML emails with Macro Scheduler ?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
virg.gaillard
Newbie
Posts: 6
Joined: Tue Feb 08, 2005 1:22 pm

Is it possible to send HTML emails with Macro Scheduler ?

Post by virg.gaillard » Tue Feb 08, 2005 1:27 pm

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

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Feb 08, 2005 4:05 pm

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.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

virg.gaillard
Newbie
Posts: 6
Joined: Tue Feb 08, 2005 1:22 pm

Post by virg.gaillard » Wed Feb 09, 2005 8:40 am

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).

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Feb 09, 2005 9:41 am

Which email clients have you tested with?
MJT Net Support
[email protected]

virg.gaillard
Newbie
Posts: 6
Joined: Tue Feb 08, 2005 1:22 pm

Post by virg.gaillard » Wed Feb 09, 2005 10:17 am

Outlook, Lotus Notes, webmails

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Feb 09, 2005 11:22 am

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
Last edited by support on Wed Feb 09, 2005 3:27 pm, edited 1 time in total.
MJT Net Support
[email protected]

virg.gaillard
Newbie
Posts: 6
Joined: Tue Feb 08, 2005 1:22 pm

Post by virg.gaillard » Wed Feb 09, 2005 3:17 pm

Thank you for your help ! It works very well :D

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Sat Dec 08, 2007 2:10 am

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
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 - :-)

clate
Newbie
Posts: 11
Joined: Wed Nov 29, 2006 2:34 am

interested in update

Post by clate » Thu Jan 03, 2008 7:50 pm

trying out this code and get

Microsoft VBScript runtime error: 450

Wrong number of arguments or invalid property assignment: 'SendEmail'

Line2, Column 0

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts