merlinsdemon
05-18-2015, 05:25 AM
Hi all,
I'm making a macro to copy some information from an outlook mail item, to the clipboard. Everything is working exactly as I want, except one thing. When I obtain the Message body from the Mail Item, if it's a ongoing chain, it copies the entire chain. I just want to copy the most recent received information(message body). Here is my Macro.
Sub Copy_Forward()
Dim oMail As MailItem
Dim DataObj As MSForms.DataObject
Dim str1 As String
Dim str2 As String
Dim str3a As String
Dim str3b As String
Dim str4 As String
Dim str5 As String
Set oMail = ActiveExplorer().Selection.Item(1)
Set DataObj = New MSForms.DataObject
str1 = "From: " + oMail.SenderName + Chr(13)
str2 = "Sent: " + Format(oMail.SentOn, "dddd MMMM d,yyyy h:mm AMPM") + Chr(13)
str3a = "To: "
For Each Recipient In oMail.Recipients
str3b = str3b + Recipient.Address + "; "
Next Recipient
str4 = Chr(13) + "Subject: " + oMail.Subject
str5 = Chr(13) + oMail.Body
DataObj.SetText str1 & str2 & str3a & str3b & str4 & str5
DataObj.PutInClipboard
End Sub
I'm making a macro to copy some information from an outlook mail item, to the clipboard. Everything is working exactly as I want, except one thing. When I obtain the Message body from the Mail Item, if it's a ongoing chain, it copies the entire chain. I just want to copy the most recent received information(message body). Here is my Macro.
Sub Copy_Forward()
Dim oMail As MailItem
Dim DataObj As MSForms.DataObject
Dim str1 As String
Dim str2 As String
Dim str3a As String
Dim str3b As String
Dim str4 As String
Dim str5 As String
Set oMail = ActiveExplorer().Selection.Item(1)
Set DataObj = New MSForms.DataObject
str1 = "From: " + oMail.SenderName + Chr(13)
str2 = "Sent: " + Format(oMail.SentOn, "dddd MMMM d,yyyy h:mm AMPM") + Chr(13)
str3a = "To: "
For Each Recipient In oMail.Recipients
str3b = str3b + Recipient.Address + "; "
Next Recipient
str4 = Chr(13) + "Subject: " + oMail.Subject
str5 = Chr(13) + oMail.Body
DataObj.SetText str1 & str2 & str3a & str3b & str4 & str5
DataObj.PutInClipboard
End Sub