如何检查电子邮件是已发送或接收的草稿? (OpenEdge 11)

发布于 2025-02-01 15:46:32 字数 739 浏览 1 评论 0原文

我正在尝试创建一种方法来检查给定的电子邮件(来自Outlook本身或MSG文件)是发送,已接收还是草稿电子邮件。我可以比较它是否是在其他地方发送或收到的,而且效果很好,但这是确定是否是草稿的部分。以下是我目前拥有的。

        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".

如果电子邮件没有附件,它可以正常工作,因为草稿的价值总是8个,但是一旦添加附件,它就会变得很奇怪,因此我无法降低范围诸如24和242613之类的值时,带有附件的发送电子邮件的值为49)。任何人都知道一种更聪明的方法来告诉它是否是草稿吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岁吢 2025-02-08 15:46:32

我从来没有与Outlook和内部进步一起工作的良好经验...我在项目上完成的工作是与C#创建自定义DLL并将其集成到我的系统中。

因此,我有一个char,可以触发我的DLL中的某些过程,并发送和接收电子邮件(保存为.msg),从而使我的进度代码更容易管理。

就您而言,您应该尝试这样的事情:
Outlook MailItem:如何区分邮件是否正在启动或外向?

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?

友谊不毕业 2025-02-08 15:46:32

我发现的解决方案是使用c# DLL使用Interop将电子邮件转换为Outlook Mail项目:

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;
    }

我必须发布电子邮件对象,以便进一步的代码不会破坏。

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.

彼岸花ソ最美的依靠 2025-02-08 15:46:32
IF L-EMAIL-FLAG = 8 THEN

请用以下代码替换上线。希望这对您有帮助。

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

我与Aspose一起担任开发人员传教士。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文