none
Outlook 2007 Email Macro RRS feed

  • Question

  • I have the following code in a Module as a Macro that creates an email without the default signature page and the words that I put in the code that show up as "Love You, Dad"

    So is there a way to adjust the code so that before the words in the email from the macro, there are two or three line spaces before the words "Love You, Dad" and is there a way to have the words Love You as a line and then a line space after those words and then the word Dad, so it looks like

    Love You,

    Dad

    Here is the macro that creates the email form:


    Public Sub E_Mail_From_Dad()

    Set oContact = GetCurrentItem()

    Dim objMsg As MailItem

    ' Blank message
    ' Set objMsg = Application.CreateItem(olMailItem)

    Set objMsg = Application.CreateItem(olMailItem)
     objMsg.HTMLBody = "Love You, Dad"
     objMsg.To = oContact.Email1Address
     objMsg.Subject = "From Dad"

     'displays the message form so you can enter more text
      objMsg.Display
     
      'use this to send to outbox
      'objMsg.Send

      Set objMsg = Nothing

    End Sub

    Function GetCurrentItem() As Object
        Dim objApp As Outlook.Application
              
        Set objApp = Application
        On Error Resume Next
        Select Case TypeName(objApp.ActiveWindow)
            Case "Explorer"
                Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
            Case "Inspector"
                Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
        End Select
          
        Set objApp = Nothing
    End Function

    Thursday, August 8, 2013 9:18 PM

Answers

  • To All,

    I learned how to do what I asked, and here is the macro code that does it:

    Public Sub E_Mail_From_Dad()

    Set oContact = GetCurrentItem()

    Dim objMsg As MailItem
    Dim sMsgBody As String

    ' Blank message
    ' Set objMsg = Application.CreateItem(olMailItem)

    Set objMsg = Application.CreateItem(olMailItem)
     sMsgBody = vbCrLf & vbCrLf
     sMsgBody = sMsgBody & "Love You;"
     sMsgBody = sMsgBody & vbCrLf & vbCrLf
     sMsgBody = sMsgBody & "Dad"
     objMsg.To = oContact.Email1Address
     objMsg.Subject = "From Dad"
     objMsg.BodyFormat = olFormatRichText
     objMsg.Body = sMsgBody
     
      'displays the message form so you can enter more text
      objMsg.Display
     
      'use this to send to outbox
      'objMsg.Send

      Set objMsg = Nothing

    End Sub

    Thursday, August 8, 2013 11:59 PM

All replies

  • To All,

    I learned how to do what I asked, and here is the macro code that does it:

    Public Sub E_Mail_From_Dad()

    Set oContact = GetCurrentItem()

    Dim objMsg As MailItem
    Dim sMsgBody As String

    ' Blank message
    ' Set objMsg = Application.CreateItem(olMailItem)

    Set objMsg = Application.CreateItem(olMailItem)
     sMsgBody = vbCrLf & vbCrLf
     sMsgBody = sMsgBody & "Love You;"
     sMsgBody = sMsgBody & vbCrLf & vbCrLf
     sMsgBody = sMsgBody & "Dad"
     objMsg.To = oContact.Email1Address
     objMsg.Subject = "From Dad"
     objMsg.BodyFormat = olFormatRichText
     objMsg.Body = sMsgBody
     
      'displays the message form so you can enter more text
      objMsg.Display
     
      'use this to send to outbox
      'objMsg.Send

      Set objMsg = Nothing

    End Sub

    Thursday, August 8, 2013 11:59 PM
  • Is there a way to make just the automatic words of the Body as bold, but when you type in other words they are not bold?
    Saturday, August 10, 2013 11:18 PM