2017-10-14 6 views
1

Ich habe einen Arbeitscode geschrieben, um auf eine E-Mail in einem bestimmten Format zu antworten, aber das Ergebnis fehlt einige Informationen für die zuletzt empfangene E-Mail im HTML-Text (Von, gesendet, an , cc, subject.Ich bin nicht einmal sicher, ob dies der Mail-Header genannt wird).VBA, um eine E-Mail zu beantworten, aber einige Informationen fehlen

Wenn ich auf die Outlook 2013 Standard "Antwort" -Schaltfläche klicke, wären diese Informationen vor der letzten E-Mail automatisch generiert worden, während darüber dann mein Antwortinhalt gewesen wäre.

Welche Funktion sollte ich verwenden, um diese Informationen auszurufen? Die Informationen müssen in allen meinen Antworten erscheinen, also muss ich es auf die eine oder andere Weise herausfinden. Mein Code:

'there is a getsignature function before the code. 
Public Sub my_reply() 
Dim objOL As Outlook.Application 
Dim objMsg As Object 
Dim objSelection As Outlook.Selection 
Dim objMail As Outlook.mailitem 
Dim StrSignature As String 


StrSignature = GetSignature("C:\Users\xxx\xxx\Microsoft\Signatures\ABC.htm") 


Set objOL = CreateObject("Outlook.Application") 
Set objSelection = objOL.ActiveExplorer.Selection 
For Each objMsg In objSelection 
    If objMsg.Class = olMail Then 
     objMsg.Categories = "Category A" 

Set myreply = objMsg.Reply 
myreply.To = objMsg.SenderEmailAddress 
myreply.BCC = "[email protected]" & " ; " & "[email protected]" 
myreply.Subject = "XYZ matter" & objMsg.Subject 
myreply.Display 
myreply.HTMLBody = StrSignature & "<br><br>" & objMsg.HTMLBody 


Release: 
    Set objMsg = Nothing 
    Set oExplorer = Nothing 

    End If 

    Next 

End Sub 

Danke in fortgeschrittenem.

+0

'Versuche Set myreply = objMsg.ReplyAll' – niton

+0

Ich habe versucht, aber es doesn‘ t machen einen Unterschied. Danke trotzdem. –

+0

Bitte nicht gelöst zu Titel statt posten/akzeptieren Antwort, die für Sie nützlich war sehen [Tour] –

Antwort

1

ReplyAll sollte die cc bekommen. Wenn Sie nur über fehlenden Text besorgt sind, ignorieren Sie dies.

Set myReply = objMsg.ReplyAll 

Sie überschreiben die anfängliche myreply.HTMLBody mit objMsg.HTMLBody

myreply.HTMLBody = StrSignature & "<br><br>" & objMsg.HTMLBody 

anhängen Statt auf die anfängliche myreply.HTMLBody

Option Explicit 

Public Sub my_replyAll() 

'Dim objOL As Outlook.Application 
Dim objMsg As Object 
Dim objSelection As Selection 

'Dim objMail As Outlook.mailitem 
Dim myReply As mailitem 

Dim StrSignature As String 

StrSignature = GetSignature("C:\Users\xxx\xxx\Microsoft\Signatures\ABC.htm") 

' Set objOL = CreateObject("Outlook.Application") 
'Set objSelection = objOL.ActiveExplorer.Selection 
Set objSelection = ActiveExplorer.Selection 

For Each objMsg In objSelection 

    If objMsg.Class = olMail Then 

     Set myReply = objMsg.ReplyAll 

     myReply.To = objMsg.SenderEmailAddress 

     myReply.BCC = "[email protected]" & " ; " & "[email protected]" 

     myReply.Subject = "XYZ matter " & objMsg.Subject 

     myReply.Display 

     'myReply.HtmlBody = StrSignature & "<br><br>" & objMsg.HtmlBody 
     myReply.HtmlBody = StrSignature & "<br><br>" & myReply.HtmlBody 

Release: 
     Set objMsg = Nothing 

    End If 

Next 

End Sub 
+0

Das funktioniert und vielen Dank Niton! :) –

Verwandte Themen