Exemplo n.º 1
0
 /// <summary>
 /// Create a new instance of an EmailMessage.
 /// </summary>
 public EmailMessage()
 {
     _mimeboundary=new MimeBoundary();
     _charset=System.Text.Encoding.GetEncoding(Configuration.GetInstance().GetDefaultEncoding("iso-8859-1"));
     _bodytext=GetNoMimeMessage();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Encode the email body as it will appear in the email
        /// </summary>
        /// <returns>the encoded body</returns>
        internal String ToDataStringBody()
        {
            bool mixedistop=false;
            bool relatedistop=false;
            bool alternativeistop=false;

            if (HasBodyTextOnly())
            {
                return FormatBodyText(_bodytext);
            }

            MimeBoundary relatedcontentmimeboundary=null;
            MimeBoundary mixedcontentmimeboundary=null;
            MimeBoundary altertnativecontentmimeboundary=null;

            #region Determine which uses the top-level boundary
            if (HasMixedContent())
            {
                mixedistop=true;
                mixedcontentmimeboundary=_mimeboundary;
                relatedcontentmimeboundary=new MimeBoundary();
                altertnativecontentmimeboundary=new MimeBoundary();
            }
            else if (HasRelatedContent())
            {
                relatedistop=true;
                relatedcontentmimeboundary=_mimeboundary;
                altertnativecontentmimeboundary=new MimeBoundary();
            }
            else
            {
                alternativeistop=true;
                altertnativecontentmimeboundary=_mimeboundary;
            }
            #endregion

            MimeContainer alternativemimecontainer=new MimeContainer(altertnativecontentmimeboundary, "multipart/alternative", alternativeistop);
            MimeContainer topcontainer=alternativemimecontainer;

            #region Text & HTML Parts
            if (_textpart!=null)
            {
                alternativemimecontainer.AddAttachment(_textpart);
            }

            if (_htmlpart!=null)
            {
                alternativemimecontainer.AddAttachment(_htmlpart);
            }
            #endregion

            #region Related Content
            if (HasRelatedContent())
            {
                //topcontainer=new MimeContainer(relatedcontentmimeboundary, "multipart/related", relatedistop);
                topcontainer=new MimeContainer(relatedcontentmimeboundary, "multipart/related;\r\n       type=\"multipart/alternative\"", relatedistop);
                topcontainer.AddMimeContainer(alternativemimecontainer);
                foreach (FileAttachment attachment in _relatedfileattachments)
                {
                    topcontainer.AddAttachment(attachment);
                }
            }
            #endregion

            #region Mixed Content
            if (HasMixedContent())
            {

                MimeContainer oldtopcontainer=topcontainer;
                topcontainer=new MimeContainer(mixedcontentmimeboundary, "multipart/mixed", mixedistop);
                topcontainer.AddMimeContainer(oldtopcontainer);

                foreach (FileAttachment attachment in _mixedfileattachments)
                {
                    topcontainer.AddAttachment(attachment);
                }

            }
            #endregion

            if (_bodytext==null)
            {
                return topcontainer.ToDataString();
            }
            else
            {
                return FormatBodyText(_bodytext)+".\r\n\r\n"
                    +topcontainer.ToDataString();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new instance of an EmailMessage.
 /// </summary>
 public EmailMessage()
 {
     _mimeboundary = new MimeBoundary();
     _charset      = System.Text.Encoding.GetEncoding(Configuration.GetInstance().GetDefaultEncoding("iso-8859-1"));
     _bodytext     = GetNoMimeMessage();
 }
Exemplo n.º 4
0
        /// <summary>
        /// Encode the email body as it will appear in the email
        /// </summary>
        /// <returns>the encoded body</returns>
        internal String ToDataStringBody()
        {
            bool mixedistop       = false;
            bool relatedistop     = false;
            bool alternativeistop = false;

            if (HasBodyTextOnly())
            {
                return(FormatBodyText(_bodytext));
            }

            MimeBoundary relatedcontentmimeboundary      = null;
            MimeBoundary mixedcontentmimeboundary        = null;
            MimeBoundary altertnativecontentmimeboundary = null;

            #region Determine which uses the top-level boundary
            if (HasMixedContent())
            {
                mixedistop = true;
                mixedcontentmimeboundary        = _mimeboundary;
                relatedcontentmimeboundary      = new MimeBoundary();
                altertnativecontentmimeboundary = new MimeBoundary();
            }
            else if (HasRelatedContent())
            {
                relatedistop = true;
                relatedcontentmimeboundary      = _mimeboundary;
                altertnativecontentmimeboundary = new MimeBoundary();
            }
            else
            {
                alternativeistop = true;
                altertnativecontentmimeboundary = _mimeboundary;
            }
            #endregion

            MimeContainer alternativemimecontainer = new MimeContainer(altertnativecontentmimeboundary, "multipart/alternative", alternativeistop);
            MimeContainer topcontainer             = alternativemimecontainer;

            #region Text & HTML Parts
            if (_textpart != null)
            {
                alternativemimecontainer.AddAttachment(_textpart);
            }

            if (_htmlpart != null)
            {
                alternativemimecontainer.AddAttachment(_htmlpart);
            }
            #endregion

            #region Related Content
            if (HasRelatedContent())
            {
                //topcontainer=new MimeContainer(relatedcontentmimeboundary, "multipart/related", relatedistop);
                topcontainer = new MimeContainer(relatedcontentmimeboundary, "multipart/related;\r\n       type=\"multipart/alternative\"", relatedistop);
                topcontainer.AddMimeContainer(alternativemimecontainer);
                foreach (FileAttachment attachment in _relatedfileattachments)
                {
                    topcontainer.AddAttachment(attachment);
                }
            }
            #endregion

            #region Mixed Content
            if (HasMixedContent())
            {
                MimeContainer oldtopcontainer = topcontainer;
                topcontainer = new MimeContainer(mixedcontentmimeboundary, "multipart/mixed", mixedistop);
                topcontainer.AddMimeContainer(oldtopcontainer);

                foreach (FileAttachment attachment in _mixedfileattachments)
                {
                    topcontainer.AddAttachment(attachment);
                }
            }
            #endregion

            if (_bodytext == null)
            {
                return(topcontainer.ToDataString());
            }
            else
            {
                return(FormatBodyText(_bodytext) + ".\r\n\r\n"
                       + topcontainer.ToDataString());
            }
        }
Exemplo n.º 5
0
 public MimeContainer(MimeBoundary mimeboundary, String contenttype, bool istoplevel)
 {
     this._mimeboundary=mimeboundary;
     this._contenttype=contenttype;
     this._istoplevel=istoplevel;
 }
Exemplo n.º 6
0
 public MimeContainer(MimeBoundary mimeboundary, String contenttype, bool istoplevel)
 {
     this._mimeboundary = mimeboundary;
     this._contenttype  = contenttype;
     this._istoplevel   = istoplevel;
 }