Link to home
Start Free TrialLog in
Avatar of cjones_mcse
cjones_mcseFlag for United States of America

asked on

Open new Outlook message with email address and subject line complete but body blank

Basically I just need to know how to make the new Outlook message open. I know how to do the rest.

Here is the code I currently have:

Dim objOutlook As New Outlook.Application
Dim objEmail As Outlook.MailItem
Dim strLtrContent As String
   
strLtrContent = "Dear " & FIRST_NAME.Value & " " & _
                 LAST_NAME.Value & ":" & vbCrLf & vbCrLf & _
                 "Your SITE account password is: " & Password.Value & _
                 vbCrLf & vbCrLf & "Please wait 24 hours before attempting to change your password." & _
                 vbCrLf & vbCrLf & "If you have questions or issues with MySite, please contact:" & _
                 vbCrLf & "John Doe (mailto:John.Doe@mysite.com)" & vbCrLf & _
                 "Jack Doe(mailto:Jack.Doe@mysite.com) or" & vbCrLf & _
                 "Jane Doe (mailto:Jane.Doe@mysite.com)" & vbCrLf

Set objEmail = objOutlook.CreateItem(olMailItem)
objEmail.Recipients.Add Email.Value
objEmail.Subject = "Your Account"
objEmail.Body = strLtrContent
objEmail.Send

So instead of sending this email, I just want it to fill in the recipient info (objEmail.Recipients.Add Email.Value) and the subject line (objEmail.Subject = "Your Account" and then open the message so I can write a personalized email. How do I modify this code to achieve this?
Avatar of DrDamnit
DrDamnit
Flag of United States of America image

What version of Outlook do you have? Some of the later versions don't quite work properly. I have 2003, and ended up copying the address to the clipboard so that when the message displayed, all I have to do is paste it in.

Tacky, but works for me.
ASKER CERTIFIED SOLUTION
Avatar of edwardiii
edwardiii

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ShelfieldCollege
ShelfieldCollege

If outlook is your default mail client then I think you can do it by simply 'shell'ing the mailto:me@myhouse.com?subject=this%20is%20the%20subject  e.g.

Add the following declaration
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

then use

call ShellExecute(hwnd, "Open", "mailto:user@domain.com?subject=This%20is%20the%20subject", "", app.path, 1)

It should open a new email message with the default client and fill in the subject and to fields, obviously this is only useful to yourself if the default client is Outlook

Cheers

/Matt
Avatar of cjones_mcse

ASKER

Awesome Ed!  Thanks a ton!