Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 30th, 2004, 01:19 AM
Registered User
Join Date: Jan 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rambhias
Default Sending email thru Outlook Exp. from VB with html


I want to send automated emails through outlook express using my VB application. The specific requirement is to send the html ow rod formatted text as body of the email. I dont want to send it as an attachment. Mostly, i'll get the data directly from some Word Doc or HTML file or I may use crystal report to generate HTML or Word Doc at run time and then send that text as a body in email. Importantly, the email should not go as an attachment the formatted text must be in body. Is there any way I can achieve the same? If poss. plz. do let me know. Thanks.
Old February 27th, 2004, 04:18 PM
Registered User
Join Date: Feb 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

I am having the same problem. I have a C# console app that automates the sending of emails and i need to insert html script as the body.

Old March 10th, 2004, 08:30 PM
Authorized User
Join Date: Feb 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts

Reasonably easy to do: (If I have the right end of the stick!)

1. Right - click your object browser and click components

2. In the Controls tab, choose Microsoft MAPI controls(whichever version)and click OK

3.Add a MAPISession control, a MAPIMessages control and a Command button to a form
Leave them as their original names...

4. Add the following code, putting your e-mail address and recipient address in place of examples :D

Private Sub Command1_Click()

'Create a simple html output for message

stroutput = "<html><div align=""center""><h1>HELLO WORLD</h></div></html>"

'MAPISession1.UserName = "[email protected]"
'MAPISession1.Password = "password" You may or may not need these

MAPIMessages1.SessionID = MAPISession1.SessionID
MAPIMessages1.RecipAddress = "[email protected]"

MAPIMessages1.MsgSubject = "VBTest"
MAPIMessages1.MsgNoteText = stroutput

End Sub

This works with my Outlook Express settings but dont forget to allow other programs to send mail in whatever mail application you use

Old July 7th, 2004, 08:46 PM
Registered User
Join Date: Jul 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts


I tried your suggestion in a VB 6 app using MAPI to create emails through Outlook 2003.

I created the stroutput exactly as you have it, and put it in my MAPIMessages1.MsgNoteText.

The problem is that the email comes out with the HTML commands as raw text instead of the interpreted HTML. In other words, the first line of the email reads:

<html><div aling=""center""><h1>HELLO WORLD</h></div></html>

Any thoughts on why this worked for you in Outlook Express but not for me in Outlook?

Old November 22nd, 2004, 03:12 AM
bsa bsa is offline
Registered User
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Rambhias
I am having the same problem. Have u found a solution for it. If so, do post the same.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Email from VB.NET not using outlook hplim18 Pro VB.NET 2002/2003 2 November 23rd, 2008 04:38 AM
ASP: Sending a HTML form to an email address cancer10 Classic ASP Databases 4 February 19th, 2007 05:25 PM
Issue sending HTML file as attachment in EMail kdhawan_forum VB Components 0 April 8th, 2005 02:02 PM
Sending an email without Outlook SaharaWizard Pro VB 6 3 August 12th, 2004 04:15 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.