2017-10-14 8 views
1

J'ai écrit un code de travail pour répondre à un e-mail dans un certain format, mais le résultat manque certaines informations pour le dernier e-mail reçu dans le corps Html (De, envoyé, , cc, sujet Je ne suis même pas sûr si cela s'appelle l'en-tête de courrier).VBA pour répondre à un e-mail mais des informations sont manquantes

Si je clique sur le bouton 'réponse' par défaut d'Outlook 2013, ces informations auraient été générées automatiquement avant le dernier e-mail, alors qu'au-dessus, ce serait mon contenu de réponse.

Alors quelle fonction dois-je utiliser pour appeler ces informations? L'info doit apparaître dans toutes mes réponses, donc j'ai besoin de la comprendre d'une façon ou d'une autre. Mon 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 

Merci à l'avance.

+0

Essayez 'Set MyReply = objMsg.ReplyAll' – niton

+0

J'ai essayé, mais il n » t faire n'importe quelle différence. Merci quand même. –

+0

S'il vous plaît ne pas ajouter résolu au titre à la place/accepter la réponse qui était utile pour vous voir [tour] –

Répondre

1

ReplyAll devrait obtenir le cc. Si vous êtes seulement préoccupé par le texte manquant ignorez ceci.

Set myReply = objMsg.ReplyAll 

Vous écrasez la myreply.HTMLBody initiale avec objMsg.HTMLBody

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

append Au lieu de cela la première 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

Cela fonctionne et merci beaucoup Niton! :) –