Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Mail

Status
Not open for further replies.

clayton74

Technical User
Apr 17, 2002
187
GB
Hello
I am new to VB6 so sorry for any dumb questions

I have a form that users will enter data, what I need to do is to press a button it will open a new mail using Outlook with the data in the body of the message.
I am not expecting anybody to do this for me but I require guidance :)

Many thanks
 
Open a code window and add a reference to the Microsoft Outlook object library of whichever version you need or have installed.

From then on, there are many code samples available in automating the creation of Outlook email items via VBA code, so its simply a matter of adapting it to your requirements (message content, subject line, to address etc).

John

 
Many thanks JRBarnett worked well, may I ask another question
How would I show the mail before sending, I have the following in my project as a test but would like to view the compiled mail before sending

Dim oOutlook As Object
Dim oItem As Object

Set oOutlook = CreateObject("Outlook.Application")
Set oItem = oOutlook.CreateItem(0)

With oItem
.Subject = "Call Ref" & txtxpref.Value
.To = txtxpto.Value
.Body = "This is a test"
.Send
End With

Thanks in advance
 
Replace .Send with .Display

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top