Markierter Mail Kat. zuweisen
25.01.2023 08:40:09
Claus
ich habe untenstehenden Code um eine E-Mail zu erstellen als Antwort.
Nun möchte ich die markierte E-Mail im Outlook, auf die ich auch antworte, einer Kategorie zuordnen.
Ich habe in der Recherche bereits den .Categories = "Name" Code gefunden allerdings markiert dieses nur die Mail die ich als reply aus Excel erstelle (Entwurf bzw. gesendete Nachricht).
Kann mir jemand helfen und mir sagen welchen Code ich nehmen muss bzw. wo dieser stehen sollte damit ich die markierte E-Mail im Outlook zuordnen kann?
Als nächsten Punkt würde ich die markierte Mail auch gerne als "erledigt" (grüner Haken) in Outlook markieren, ist dies auch per VBA möglich?
LineReplyMail:
''_______________Send REPLY MAIL WITH SIGNATURE______________
Dim OutlookApp As Object
Dim OutlookMail As Object
On Error GoTo LineKeineMail
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.ActiveExplorer.Selection.Item(1)
'~~> Get MailItem.GetConversation method (Outlook)
' https://learn.microsoft.com/en-us/office/vba/api/outlook.mailitem.getconversation
Dim OutlookConversation As Object
Set OutlookConversation = OutlookMail.GetConversation
On Error GoTo LineKeineMail
'~~> Conversation.GetTable method (Outlook)
' https://learn.microsoft.com/en-us/office/vba/api/outlook.conversation.gettable
Dim OutlookTable As Object
Set OutlookTable = OutlookConversation.GetTable
On Error GoTo LineKeineMail
'~~> Obtains a 2D array from the Table.
' https://learn.microsoft.com/en-us/office/vba/api/outlook.table.getarray
Dim OutlookAr As Variant
OutlookAr = OutlookTable.GetArray(OutlookTable.GetRowCount)
On Error GoTo LineKeineMail
Dim OutlookReplyToThisMail As Object
Set OutlookReplyToThisMail = OutlookMail.Session.GetItemFromID(OutlookAr(UBound(OutlookAr), 0))
On Error GoTo LineKeineMail
With OutlookReplyToThisMail.Reply
.Categories = "Name"
.SentOnBehalfOfName = "meine@emailadresse.de"
.To = sKMail
.CC = sAEMail
.BodyFormat = 2
.HTMLBody = sText & .HTMLBody
.Display
End With
GoTo LineCreateTimestamp
''^^^^^^^^^_______________Send REPLY MAIL WITH SIGNATURE______________^^^^^^^^^