Question : How to get outlook IMessage return-path

We require to get "return-path property of  IMessage.
Application uses office 2003 object model and reading mails from inbox.
We need to get the value of  return-path of each mail item programmatically.
I am using .net 2005 in XP Box.
Regards.
Pramod Kumar.

Answer : How to get outlook IMessage return-path

Here you go.  Pass it any mailitem and you'll get the return path back if it is in the message header.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
Function GetReturnPath(olkItem As Outlook.MailItem) As String
    Const CdoPR_TRANSPORT_MESSAGE_HEADERS = &H7D001E
    Dim objUtils As Object, _
        strHeader As String, _
        arrHeaders As Variant, _
        varHeader As Variant
    Set objUtils = CreateObject("Redemption.MAPIUtils")
    strHeader = objUtils.HrGetOneProp(olkItem.MAPIOBJECT, CdoPR_TRANSPORT_MESSAGE_HEADERS)
    If Err.Number = 0 Then
        arrHeaders = Split(strHeader, vbCrLf)
        For Each varHeader In arrHeaders
            If Left(LCase(varHeader), 12) = "return-path:" Then
                GetReturnPath = Trim(Mid(varHeader, 13))
                Exit For
            End If
        Next
    End If
    Set objUtils = Nothing
End Function
Open in New Window Select All
Random Solutions  
 
programming4us programming4us