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

Senior 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.
 
Similar threads
Thread starter Title Forum Replies Date
M Filter rules to distinguish To and CC fields Outlook VBA and Custom Forms 1
glnz O365 - How to control whether my From name shows as "Dicky". Using Outlook 1
S exchange power shell whether run on scheduler Exchange Server Administration 4
M Auto-reply with macro whether logged in to outlook or not Outlook VBA and Custom Forms 2
D Check whether mail item is proper for sending or not Outlook VBA and Custom Forms 5
H out to check whether outlook configured or not Outlook VBA and Custom Forms 1
Q Re: Detecting whether a toolbar is and should be shown Outlook VBA and Custom Forms 5
L Correct E-Mail Pulling Wrong Mail Using Outlook 5
S Outlook mail adressing stops after first match in GAL Using Outlook 0
P Outlook 2013 All imported Mail Rules in error when imported into new profile Using Outlook 5
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
S Outlook Macro to move reply mail based on the key word in the subjectline Outlook VBA and Custom Forms 0
MrMayor SENT mail not reloading to top?? Using Outlook 4
Terry Sullivan Sender Field Displays My E-Mail Address, Not My Name Using Outlook 1
ThinkToday Calculate reply time of outlook mail Using Outlook 1
B Outlook 2010 Opening Mail Attachment Using Outlook 2
e_a_g_l_e_p_i Is it possible it set the fonts used to read incoming mail Using Outlook 25
D Mail in Sent Items Gone Using Outlook 12
M Managing Gmail "All Mail" sync issues with IMAP Using Outlook 1
GregS Outlook 2016 Sent Mail absent from Sent Mail or Sent Items Folders Using Outlook 4
GregS Why is Outlook 2016 mail in Outlook.com? Using Outlook 1
S Outlook not receiving mail Using Outlook 1
Commodore Outlook (2013) issues with icloud.com mail Using Outlook 0
GregS Outlook 2016 iPhone won't download Outlook 2016 Mail. Using Outlook 0
A Arthur needs help with 2007 Outlook e-mail Using Outlook.com accounts in Outlook 3
W Receiving mail for account that has been deleted Using Outlook 2
H In outlook 365 POP mail Inbox, email takes a long time or never arrives. Using Outlook 1
Z Add text to auto-forwarded e-mail Outlook VBA and Custom Forms 4
K HOW TO FIX AOL MAIL ISSUES? Using Outlook 0
O How to prevent CC from showing when creating a new mail? Using Outlook 1
I Junk Mail and PersonMetadata Using Outlook 2
T 3 months of archived e-mail is missing Using Outlook 1
B Outlook - Mail from safe senders list being sent to Spam Folder Using Outlook 0
G Detect Google Drive and OneDrive links in incoming mail Outlook VBA and Custom Forms 3
M Sent mail not showing in Sent Items folder; but they can be found with Search Using Outlook 3
H Outlook 2016 sent over 30 copies of an e-mail with attachments Using Outlook 1
T Missing text in e-mail message after "(Please keep confidential)" Using Outlook 3
Victor_50 Outlook 2013 Custom Contact Form starts with "E-mail 2" Outlook VBA and Custom Forms 2
E Mail sorting view issue Using Outlook 1
D after delete mail, open the next one Outlook VBA and Custom Forms 0
RBLampert Assigning a newly (re)created e-mail account to a specific .pst data file Using Outlook 2
B Clear Offline Items (Mail Folder) via VBA Outlook VBA and Custom Forms 1
M Moving mail to another folder is much slower than before (Office365) Using Outlook 0
A Outlook macro to create search folder with mail categories as criteria Outlook VBA and Custom Forms 3
N VBA Script to Open highlighted e-mail and Edit Message Outlook VBA and Custom Forms 5
M Auto-export mail to Excel Outlook VBA and Custom Forms 2
M Sent mail not showing in my sent folder Using Outlook 9
B iCloud Option to sync contacts, mail, calendar and tasks Using Outlook 5
O Using .OST and .PST mail thru different providers Using Outlook 5
CWM030 Connected accounts mail moved to trash? Exchange Server Administration 16

Similar threads

Top