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

Posted on 2005-04-22
Medium Priority
Last Modified: 2012-06-27
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

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?
Question by:cjones_mcse
LVL 32

Expert Comment

ID: 13847547
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.
LVL 10

Accepted Solution

edwardiii earned 1000 total points
ID: 13847626
Hi, cjones_mcse.

I haven't tested your code above, but if it populates the body of an email and sends it, and you just want a new email to open so you can populate the body yourself and send it manually,
just REM out the last two lines of code:

     'objEmail.Body = strLtrContent

However, it is Friday evening, so maybe I entirely misunderstood your question.  In any event, here's the code I use.  The main thing I've noticed when manipulating Outlook 2000 is that it ignores all instances of "vbNewLine", so I have to do a replace with "<br>":

    Dim outApp As Outlook.Application
    Dim olMail As MailItem
    Set outApp = New Outlook.Application
    Set olMail = outApp.CreateItem(olMailItem)

    Dim strTemplate, strSubject As String
    Dim strTxtAllConvert As String
    strTxtAllConvert = Replace(txtAll.Text, vbNewLine, "<br>")
    strTemplate = strTxtAllConvert

     'required to control the HTML body font:
    Dim strFontControlBody As String
    strFontControlBody = "<font face = MS Sans Serif size=3>" & strTemplate & "</font>"
    strSubject = "%& MDN: " & strMDN & "*" & strCenter & "**" & strRep & "***" & strProblemType

    With olMail
        .To = "WATSSRemedy-coordinators@nw.verizonwireless.com"
        .Subject = strSubject
         .HTMLBody = strFontControlBody
        'Line above invokes HTML control of email font; so line below no longer required
        '.Body = strTemplate
        '.Attachments.Add _
        'source:="C:\Documents and Settings\edwardiii\Images\VZW.jpg"
    End With


Expert Comment

ID: 13857485
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


LVL 10

Author Comment

ID: 13868251
Awesome Ed!  Thanks a ton!
LVL 10

Expert Comment

ID: 13869248

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month17 days, 5 hours left to enroll

864 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