0

I'm trying to create a way to check whether a given email (either from Outlook itself or an MSG file) is a sent, received or a draft email. I got the bit to compare if it was sent or received somewhere else and that works fine but it's the part that determines if it's a draft or not that is the issue. Below is what I have currently.

        L-EMAIL = Aspose.Email.Mapi.MapiMessage:FromFile(P-FILENAME).
        L-EMAIL-FLAG = Integer(L-EMAIL:Properties[Aspose.Email.Mapi.MapiPropertyTag:PR_MESSAGE_FLAGS]:ToString()).
        IF L-EMAIL-FLAG = 8 THEN
            L-EMAIL-STATUS = "DRAFT".
        ELSE
            IF L-EMAIL:Properties[Aspose.Email.Mapi.MapiPropertyTag:PR_RECEIVED_BY_ENTRYID] = ? THEN
                L-EMAIL-STATUS = "SENT".
            ELSE
                L-EMAIL-STATUS = "RECEIVED".

If there's no attachments to the emails, it works fine since the value of a draft email is always 8 but as soon as you add attachments, it gets all weird with the values so I can't get a range down (I've gotten values like 24 and 242613 while a sent email with an attachment has a value of 49). Anyone know a smarter way of telling if it's a draft or not?

Mike Fechner
  • 6,627
  • 15
  • 17

3 Answers3

2

I never had a good experience working with Outlook and Progress internally... what I've managed to accomplish on my project was to create a custom DLL with C# and integrated it on my system.

So, I have an char that triggers some procedures inside my DLL and sends and receives emails (saves as .msg), making my Progress code a lot more easier to manage.

In your case, you should try something like this: Outlook MailItem: How to distinguish whether mail is incoming or outgoing?

Raphael Frei
  • 361
  • 1
  • 10
0

Solution I found was to use a C# DLL to convert the email to an Outlook mail item using the interop:

public bool IsDraft(string path)
    {
        Outlook.Application oApp = (Outlook.Application)Marshal.GetActiveObject("Outlook.Application");
        Outlook.MailItem email = oApp.Session.OpenSharedItem(path) as Outlook.MailItem;
        bool isSent = email.Sent;
        Marshal.ReleaseComObject(email);
        email = null;
        return !isSent;
    }

I had to release the email object so that code further on wouldn't break.

codewario
  • 19,553
  • 20
  • 90
  • 159
0

The PidTagMessageFlags property value is a bitmask of flags. This means a bitwise operator must be applied to check a specific flag value.

IF L-EMAIL-FLAG = 8 THEN

Please replace above line with following line of code. Hope this helps you.

IF (L-EMAIL-FLAG AND 8) = 8 THEN

I work with Aspose as Developer Evangelist.

Tahir Manzoor
  • 597
  • 2
  • 9