Results 1 to 7 of 7

Opening a new outlook message via VBA

Threaded View

  1. #1
    Registered User
    Join Date
    06-12-2009
    Location
    Maryland
    MS-Off Ver
    Excel 2003
    Posts
    1

    Opening a new outlook message via VBA

    All-

    I am trying to create a command button in Excel that when clicked, it will open up a new Outlook email message, input a certain address in the To: field, and input a specific Subject. The following is the code that I found online earlier today but it does not work when I paste it into the VBA editor.
    Call SendEmail()
    Function SendEmail()
    Dim objOutlook, objMsg, objNameSpace, objFolder, strOutput, strSubject, StrTo, StrMsg
    StrTo = "someone@somewhere.com"
    StrMsg = InputBox ("Enter Your Message", "Enter Message", "Message Goes Here")
    Const olMailItem = 0
    Set objOutlook = CreateObject("Outlook.application")
    Set objNameSpace = objOutlook.GetNameSpace("MAPI")
    Set objMsg =  objOutlook.CreateItem(olMailItem)
    objMsg.To = StrTo
    objMsg.Display
    objMsg.HTMLBody = StrMsg
    Set objFolder = Nothing
    Set objNameSpace = Nothing
    Set objOutlook = Nothing
    Set objMsg = Nothing
    Set ss = CreateObject("WScript.Shell")
    Set ss = nothing
    End Function
    Now, the fact that it is getting an error could be my mistake since I have never created a VBA button before. Is there a basic crash course I can review for doing this and for inputting the code that is needed or can someone summarize it for me. Thank you for all of your help!
    Last edited by Leith Ross; 06-12-2009 at 08:51 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1