Exemplo n.º 1
0
        public IEMessage OpenEmbeddedMessage()
        {
            IEAttach attach = OpenAttach();

            if (attach == null)
            {
                return(null);
            }
            using ( attach )
            {
                return(attach.OpenMessage());
            }
        }
Exemplo n.º 2
0
        /**
         * Creates resources for the attachments of the specified e-mail
         * and adds them as links to the specified e-mail resource.
         */
        private void PrepareAttachments(IEMessage message)
        {
            // NOTE: IEMessage.GetAttachments() restricts the attachment table to a specific
            // set of columns, so if you need to process more columns here, don't forget to
            // modify the code in GetAttachments().
            IETable attaches = message.GetAttachments();

            if (attaches != null)
            {
                using ( attaches )
                {
                    long count = attaches.GetRowCount();
                    for (long i = 0; i < count; i++)
                    {
                        IERowSet rowSet = attaches.GetNextRow();
                        if (rowSet == null)
                        {
                            continue;
                        }
                        using ( rowSet )
                        {
                            int size         = rowSet.FindLongProp(MAPIConst.PR_ATTACH_SIZE);
                            int attachMethod = rowSet.FindLongProp(MAPIConst.PR_ATTACH_METHOD);

                            string strFileName = rowSet.FindStringProp(MAPIConst.PR_ATTACH_LONG_FILENAME);
                            if (strFileName == null)
                            {
                                strFileName = rowSet.FindStringProp(MAPIConst.PR_ATTACH_FILENAME);
                            }
                            if (strFileName == null)
                            {
                                strFileName = rowSet.FindStringProp(MAPIConst.PR_DISPLAY_NAME);
                            }
                            if (strFileName != null)
                            {
                                string strFileType = string.Empty;
                                int    dotIndex    = strFileName.LastIndexOf(".");
                                if (dotIndex != -1)
                                {
                                    strFileType = strFileName.Substring(dotIndex).ToUpper();
                                }
                                int      num          = rowSet.FindLongProp(MAPIConst.PR_ATTACH_NUM);
                                string   strContentID = null;
                                IEAttach attachment   = message.OpenAttach(num);
                                if (attachment != null)
                                {
                                    using ( attachment )
                                    {
                                        strContentID = attachment.GetStringProp(MAPIConst.PR_ATTACH_CONTENT_ID);
                                    }
                                }

                                AttachmentHelper attach =
                                    new AttachmentHelper(strFileName, strFileType, (int)i, size, attachMethod, strContentID, num);
                                _attachments.Add(attach);
                            }
                        }
                    }
                }
            }
        }