PDA

View Full Version : Outlook VBA read Recepients



zer0core
04-23-2015, 02:49 AM
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.

skatonni
04-23-2015, 12:25 PM
Try


myRecipient = oMail.Recipients.Item(1).AddressEntry.GetExchangeUser.Firstname

Note: Your code was incomplete. It is missing GetCurrentItem()

zer0core
04-24-2015, 01:20 AM
yeah thank you!