Consulting

Results 1 to 3 of 3

Thread: Outlook VBA read Recepients

  1. #1
    VBAX Newbie
    Joined
    Apr 2015
    Posts
    2
    Location

    Outlook VBA read Recepients

    Hello,
    I want 2 create a macro, which replys a mail and generate aumatically a text like "Good Morning Mr. XX"
    Here my Code:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    Sub Antworten()
    Dim olInspector As Outlook.Inspector
    Dim olDocument
    Dim olSelection
    Dim strAtt As String
    Dim strEmpfaenger As String
    Dim myRecipient As String
    Dim oItem As MailItem
    Dim oMail


    Set oItem = GetCurrentItem()

    'strEmpfaenger = Left$(oItem.SenderName, InStr(1, oItem.SenderName, ", ") - 1)

    Set oMail = oItem.Reply
    oMail.Display

    Set myRecipient = oItem.Reply.recipients.Item(1).AddressEntry.GetExchangeUser.FirstName



    strAtt = "Guten Tag "

    Set olInspector = Application.ActiveInspector()
    Set olDocument = olInspector.WordEditor
    Set olSelection = olDocument.Application.Selection

    olSelection.InsertBefore strAtt & myRecipient

    Set oMail = Nothing
    End Sub

    All is fine but the i cant read the first name of the recepient.

    Someone have an idea?

    kind regards.

  2. #2
    VBAX Mentor skatonni's Avatar
    Joined
    Jun 2006
    Posts
    347
    Location
    Try

    myRecipient = oMail.Recipients.Item(1).AddressEntry.GetExchangeUser.Firstname
    Note: Your code was incomplete. It is missing GetCurrentItem()
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

  3. #3
    VBAX Newbie
    Joined
    Apr 2015
    Posts
    2
    Location
    yeah thank you!

Posting Permissions

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