Exemple #1
0
        private static int GetAttachNum(IEMessage message, int index)
        {
            IETable table = message.GetAttachments();

            if (table == null)
            {
                return(0);
            }
            using ( table )
            {
                int count = table.GetRowCount();
                for (int i = 0; i < count; i++)
                {
                    IERowSet row = table.GetNextRow();
                    if (row != null)
                    {
                        using ( row )
                        {
                            if (index == i)
                            {
                                return(row.FindLongProp(MAPIConst.PR_ATTACH_NUM));
                            }
                        }
                    }
                    if (index < i)
                    {
                        break;
                    }
                }
            }
            return(0);
        }
Exemple #2
0
        private void PrepareRecipients(IEMessage message)
        {
            IETable recips = message.GetRecipients();

            if (recips != null)
            {
                using ( recips )
                {
                    long count = recips.GetRowCount();
                    for (long i = 0; i < count; i++)
                    {
                        IERowSet rowSet = recips.GetNextRow();
                        if (rowSet != null)
                        {
                            using ( rowSet )
                            {
                                string emailAddr = rowSet.FindStringProp(MAPIConst.PR_SMTP_ADDRESS);
                                if (emailAddr == null || emailAddr.Length == 0)
                                {
                                    emailAddr = rowSet.FindStringProp(MAPIConst.PR_EMAIL_ADDRESS);
                                }
                                if (emailAddr != null && emailAddr.Length > 0)
                                {
                                    string displayName = rowSet.FindStringProp(MAPIConst.PR_DISPLAY_NAME);

                                    bool isTo   = (rowSet.FindLongProp(MAPIConst.PR_RECIPIENT_TYPE) == (int)RecipientType.To);
                                    bool mySelf = OwnerEmailDetector.IsOwnerEmail(emailAddr);

                                    if (mySelf)
                                    {
                                        _bSentToMe = true;
                                    }
                                    _recipients.Add(new RecipientHelper(emailAddr, displayName, isTo, mySelf));
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #3
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);
                            }
                        }
                    }
                }
            }
        }