sending a html email from vbs

Posted on 2006-10-25
Medium Priority
Last Modified: 2012-08-13
I am trying to send a very simple html email message from my vb script.  However, when I try to send it, it tells me that the object does not support property or method: objMail.bodyformat.  I can send a text email just fine, I am just not sure where I am going wrong?  Any help is much appreciated.

Thank you,

Dim strHeader

'Query for Info
 'strHeader = "List of School Holidays for the Current Week."
 strHeader = "<HTML><u>List of School Holidays for the Current Week.</u><HTML>"
     MyBodyText = strHeader
     Subjectline = "List of School Holidays for the Week starting: " & Date()

'msgbox strAll

'mail code
Set Out = wscript.createobject("Outlook.Application")
     Set objNameSpace = Out.GetNamespace("MAPI")
     'Set objMail = Out.CreateItem(olMailItem)
     Set objMail = Out.CreateItem(olFormatHTML)
'msgbox "here"
           objMail.To = "test@test.com"
            'objMail.To = strTo
            objMail.Subject = Subjectline
            objMail.BodyFormat = olFormatHTML
            objMail.Body = MyBodyText
'msgbox "here1"
 'msgbox "here1"

msgbox "Mail was sent!"

     Set objMail = Nothing
     Set objNameSpace = Nothing
     Set Out = Nothing
Question by:uconnfb13
LVL 30

Expert Comment

ID: 17809083
You may get a better response if you move this to a more appropriate are like VB programming.

This has absolutely nothing to do with databases.

I suggest that you open up the VBA editor (say in Excel), and add the Outlook application library in Tools/References.

In this way you can at least get some clues as to the valid properties and methods.

Also, have you defined the constant values beforehand? Unless you tell, VBScript does not know what this is:


You shuold have a line like his beforehand:

Dim olFormatHTML

olFormatHTML = 6 ' or whatever the correct constant value is
LVL 65

Accepted Solution

rockiroads earned 1600 total points
ID: 17810118
u need to use HTMLBody, u dont set BodyFormat

objMail.HTMLBody = MyBodyText

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
I recently worked on a Wordpress site that utilized the popular ContactForm7 (https://contactform7.com/) plug-in that only sends an email and does not save data. The client wanted the data saved to a custom CRM database. This is my solution.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question