Beispiel #1
0
        public void LoadInfos()
        {
            if (!Client.IsConnected)
            {
                throw new EMailException {
                          ExceptionType = EMAIL_EXCEPTION_TYPE.NOT_CONNECTED
                }
            }
            ;
            Client.Fetch(
                true,
                IMAP_t_SeqSet.Parse(UID),
                new IMAP_t_Fetch_i[] {
                new IMAP_t_Fetch_i_Rfc822()
            },
                (sender, e) =>
            {
                if (e.Value is IMAP_r_u_Fetch)
                {
                    IMAP_r_u_Fetch fetchResp = (IMAP_r_u_Fetch)e.Value;
                    try
                    {
                        if (fetchResp.Rfc822 != null)
                        {
                            fetchResp.Rfc822.Stream.Position = 0;
                            Mail_Message mime = Mail_Message.ParseFromStream(fetchResp.Rfc822.Stream);
                            fetchResp.Rfc822.Stream.Dispose();

                            if (String.IsNullOrWhiteSpace(mime.BodyText))
                            {
                                _TextBody = mime.BodyHtmlText;
                            }
                            else
                            {
                                _TextBody = mime.BodyText;
                            }
                            Attachments.Clear();
                            foreach (MIME_Entity entity in mime.Attachments)
                            {
                                IMAP_Mail_Attachment att = new IMAP_Mail_Attachment();
                                if (entity.ContentDisposition != null && entity.ContentDisposition.Param_FileName != null)
                                {
                                    att.Text = entity.ContentDisposition.Param_FileName;
                                }
                                else
                                {
                                    att.Text = "untitled";
                                }
                                att.Body = ((MIME_b_SinglepartBase)entity.Body).Data;
                                Attachments.Add(att);
                            }
                        }
                    }
                    catch (Exception exe)
                    {
                        throw new EMailException {
                            ExceptionType = EMAIL_EXCEPTION_TYPE.ERROR_ON_GET_MESSAGE, InnerException = exe
                        };
                    }
                }
            }
                );
        }
Beispiel #2
0
        public void LoadInfos()
        {
            if (!Client.IsConnected) throw new EMailException { ExceptionType = EMAIL_EXCEPTION_TYPE.NOT_CONNECTED };
            Client.Fetch(
                true,
                IMAP_t_SeqSet.Parse(UID),
                new IMAP_t_Fetch_i[]{
                    new IMAP_t_Fetch_i_Rfc822()
                },
                (sender, e) =>
                {
                    if (e.Value is IMAP_r_u_Fetch)
                    {
                        IMAP_r_u_Fetch fetchResp = (IMAP_r_u_Fetch)e.Value;
                        try
                        {
                            if (fetchResp.Rfc822 != null)
                            {
                                fetchResp.Rfc822.Stream.Position = 0;
                                Mail_Message mime = Mail_Message.ParseFromStream(fetchResp.Rfc822.Stream);
                                fetchResp.Rfc822.Stream.Dispose();

                                if (String.IsNullOrWhiteSpace(mime.BodyText)) _TextBody = mime.BodyHtmlText;
                                else _TextBody = mime.BodyText;
                                Attachments.Clear();
                                foreach (MIME_Entity entity in mime.Attachments)
                                {
                                    IMAP_Mail_Attachment att = new IMAP_Mail_Attachment();
                                    if (entity.ContentDisposition != null && entity.ContentDisposition.Param_FileName != null)
                                    {
                                        att.Text = entity.ContentDisposition.Param_FileName;
                                    }
                                    else
                                    {
                                        att.Text = "untitled";
                                    }
                                    att.Body = ((MIME_b_SinglepartBase)entity.Body).Data;
                                    Attachments.Add(att);
                                }
                            }
                        }
                        catch (Exception exe)
                        {
                            throw new EMailException { ExceptionType = EMAIL_EXCEPTION_TYPE.ERROR_ON_GET_MESSAGE, InnerException = exe };
                        }
                    }
                }
            );
        }