Home > Blockchain >  set reply arrow via vba
set reply arrow via vba

Time:02-23

I was wondering if there is a way to add the Reply arrow to a selected mail in Outlook via VBA. The background is that we process a selected mail via VBA and create a new mail from it. This does not trigger that the original mail gets a reply arrow. It would be desirable if the mail would still get the arrow.

Best regards xsus

my new code:

 On Error Resume Next
    Select Case TypeName(Application.ActiveWindow)
        Case "Explorer"
            Set myItem = ActiveExplorer.Selection.Item(1)
        Case "Inspector"
            Set myItem = ActiveInspector.CurrentItem
    End Select
    On Error GoTo 0

    If myItem Is Nothing Then
        MsgBox "Keine Mail selektiert!", vbExclamation
        GoTo exitproc
    End If
    
    On Error GoTo NOUSER
  vorname = myItem.sender.GetExchangeUser.FirstName
  nachname = myItem.sender.GetExchangeUser.LastName
NOUSER:
   Set olNewMailItem = Application.CreateItem(olMailItem)
   If vorname = "" Then
    olNewMailItem = myItem.Reply
    olNewMailItem.HTMLBody = "<body style='font-family:Calibri; font-size:11pt;color:#000000'>" _
      & "Liebe Kollegin, lieber Kollege,<br><br>" _
      .......
      & "<br><FONT color=white>secret:</FONT>"
  Else
olNewMailItem = myItem.Reply
  olNewMailItem.HTMLBody = "<body style='font-family:Calibri; font-size:11pt;color:#000000'>" _
      & "Hallo " & vorname & ",<br><br>" _
      ......
      & "<br><FONT color=white>secret:</FONT>"
      End If
      
    olNewMailItem.Subject = "Erledigt: " & myItem.Subject & " vom " & myItem.ReceivedTime
    olNewMailItem.Attachments.Add myItem, olEmbeddeditem
    olNewMailItem.To = myItem.sender
    olNewMailItem.CC = myItem.CC
    olNewMailItem.BCC = myItem.BCC
    olNewMailItem.SentOnBehalfOfName = "xxxxxxx"
    
    olNewMailItem.Display
exitproc:
    Set myItem = Nothing
    Set olNewMailItem = Nothing

CodePudding user response:

You need to use the Forward method if you need to see the reply arrow.

CodePudding user response:

You need to set the PR_LAST_VERB_EXECUTED MAPI property (DASL name "http://schemas.microsoft.com/mapi/proptag/0x10810003") to 102 (which is EXCHIVERB_REPLYTOSENDER constant) using MailItem.PropertyAccessor.SetProperty(where MailItem comes from the Application.ActiveExplorer.Selection collection). You might also want to set the PR_LAST_VERB_EXECUTION_TIME property (DASL name "http://schemas.microsoft.com/mapi/proptag/0x10820040") to a datetime value.

You can see the property and its values in OutlookSpy (click the IMessage button).

  • Related