C#附件未显示在RDOAttachment对象中

问题描述 投票:0回答:2

尽管Outlook电子邮件在html电子邮件中有两个嵌入式图片,但我正在阅读RDOAttachment对象,.Count属性为0。

如果已将相同的代码从C#移植到Outlook中的VBA,并且在那里正确显示。

我做错什么了吗,还是RDOAttachment对象中有错误?

谢谢,托马斯

c# outlook-redemption
2个回答
0
投票

您需要保存Outlook消息以使MAPI系统(和兑换)能够看到它。


0
投票

感谢Dmitry,以下是一些有关代码的注释。我最初是在Outlook VBA中开发代码的,然后将其移植到VS C#中,因此它在其中表现出不同。

我有一封已签名的电子邮件,我想从电子邮件中删除签名,完成后,我将重新映射附件。一旦我从i_iMAPI安全消息中删除了密钥文件,i_MAPI邮件中的附件就消失了。在VBA中不是这种情况。

如何解决这个问题?

        i_iMAPI = i_rdoS.GetRDOObjectFromOutlookObject(i_rdoMessage, true);
        i_MAPI = i_rdoS.GetRDOObjectFromOutlookObject(i_rdoMessage);

        //if signed message remove key file and set MessageClass to standard Message
        if (i_iMAPI.MessageClass == "IPM.Note.SMIME.MultipartSigned")
        {
            i_iMAPI.MessageClass = "IPM.Note";
            //remove the key file and make sure it is really key file
            foreach (RDOAttachment att in i_iMAPI.Attachments)
            {
                if (att.DisplayName == "Untitled Attachment")
                {
                    att.Delete();
                }
            }

            //create specific Folder for each sender
            i_FilePath = Folders.StorageFolder + i_MAPI.SenderName;
            i_Folder.CreateFolder(i_FilePath);

            //remapp the attachements from MAPI to iMAPI Message
            foreach (RDOAttachment rdoAtt in i_MAPI.Attachments)
            {
                rdoAtt.SaveAsFile(i_FilePath + @"\" + rdoAtt.FileName);                    
                i_iMAPI.Attachments.Add(i_FilePath + @"\" + rdoAtt.FileName);                    
                i_iMAPI.Attachments[i_iMAPI.Attachments.Count].Hidden = rdoAtt.Hidden;                                        
            }
            //save changes
            i_iMAPI.Save();
        }
© www.soinside.com 2019 - 2024. All rights reserved.