Question

I need to create a email, but when the button is triggered i want it to open Outlook with a preformatted email.

Since the client have some restictions, I do not want it to send the email from the program itself, I want it to open in outlook.

Something like this:

Dim email As New CDO.Message
With email
    .From = "the_sender@company1.com"
    .To = "the_reciever@company2.com"
    .Subject = "Great e-mail"
    .HTMLBody = "<h1>Header for a cool email</h1> And cool HTML"
    .AddAttachment("Cute_kitty.jpg")

    '.Send() NO! Open outlook with this stuff typed above and make sender useless
End With

How can i do this? I found this stuff, but it does (of course) not support html-email and attachments...

Dim proc As System.Diagnostics.Process = New System.Diagnostics.Process
proc.StartInfo.FileName = "mailto:the_reciever@company2.com?subject=Great e-mail&body=My cool email that does not support html n stuff"
proc.Start()

Suggestions?

Was it helpful?

Solution

If you want to open the message in Outlook, then you need to use the Outlook Object Model. Something along the lines:

set App = CreateObject("Outlook.Application")
set NS = App.GetNamespace("MAPI")
NS.Logon
set email = App.CreateItem(0)
With email
.To = "the_reciever@company2.com"
.Subject = "Great e-mail"
.HTMLBody = Your HTML text"
.Attachments.Add("c:\temp\Cute_kitty.jpg")
.Display
End With

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top