How to distinguish whether mail is incoming or outgoing?

oliv-

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Hi,
I usually use this test to find out if the email is incoming or outgoing.
But now i see that Emails sent via the Outlook Android Application return .ReceivedByName = "My name"
and Emails sent by TypeApp (Android) return a Internet Message Header !

Code:
    Const PR_TRANSPORT_MESSAGE_HEADERS = "http://schemas.microsoft.com/mapi/proptag/0x007D001E"

    Set objmail = ActiveInspector.CurrentItem
    Set olkPA = objmail.propertyAccessor
    GetInetHeaders = olkPA.GetProperty(PR_TRANSPORT_MESSAGE_HEADERS)


    If objmail.Sent = True And objmail.ReceivedByName = "" Then
        sens = "out"
    ElseIf objmail.Sent = True And GetInetHeaders= "" Then
        sens = "out"
    ElseIf objmail.Sent = True And objmail.ReceivedByName <> "" Then
        sens = "in"
    Else
        sens = "Draft"
    End If
is there a better way ?
 

Lewis-H

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
This is how I check mail type and it works even if mail is moved to any folder. This solution uses PROPERTY ACCESSOR which is available in outlook. Below is the code
string PR_MAIL_HEADER_TAG = "schemas.microsoft.com/mapi/proptag/0x007D001E";

Outlook.PropertyAccessor oPropAccessor = mItemProp.PropertyAccessor;

string strHeader = (string)oPropAccessor.GetProperty(PR_MAIL_HEADER_TAG);

if (strHeader == "")
{
// MAIL IS OF TYPE SENTBOX
}
else
{
// MAIL IS OF TYPE INBOX
}

--
Lewis
 

oliv-

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Thank you Lewis, but i still use this property.
and sometimes for emails that i send with my smartphone (Typeapp )there is headers.
 
Top