public MailMessage()
 {
     _Recipients  = new ArrayList();       //收件人列表
     _Attachments = new MailAttachments(); //附件
     _BodyFormat  = MailFormat.HTML;       //缺省的邮件格式为HTML
     _Priority    = MailPriority.Normal;
     _Charset     = "GB2312";
 }
예제 #2
0
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                MailMessage message = new MailMessage();

                foreach (string emailid in ToEmailAddress.Get(context).Trim().Split(';'))
                {
                    message.To.Add(new MailAddress(emailid));
                }

                if (!string.IsNullOrEmpty(CCEmailAddress.Get(context)))
                {
                    foreach (string emailid in CCEmailAddress.Get(context).Trim().Split(';'))
                    {
                        message.CC.Add(new MailAddress(emailid));
                    }
                }

                if (!string.IsNullOrEmpty(BccEmailAddress.Get(context)))
                {
                    foreach (string emailid in BccEmailAddress.Get(context).Trim().Split(';'))
                    {
                        message.Bcc.Add(new MailAddress(emailid));
                    }
                }


                message.Subject    = Subject.Get(context).Trim();
                message.IsBodyHtml = IsBodyHtml.Get(context); //to make message body as html
                message.Body       = Body.Get(context).Trim();

                Console.WriteLine("----------------------");



                if (MailAttachments.Get(context) != null)
                {
                    Console.WriteLine("Number of Attachments: " + MailAttachments.Get(context).Count.ToString());
                    foreach (string file in MailAttachments.Get(context))
                    {
                        message.Attachments.Add(new Attachment(file));
                    }
                }
                out_MailMessage.Set(context, message);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.Message + "--" + e.Source);
                out_MailMessage.Set(context, null);
            }
        }
예제 #3
0
        public MailAttachments AgreementReportAttachment(int OfferId, int UserType)
        {
            ReportDA ReportDAL = new ReportDA();

            byte[] AgreementReport = ReportDAL.AgreementReportFile(OfferId, UserType);

            MailAttachments AgreementReportAttachment = new MailAttachments();

            AgreementReportAttachment.file        = AgreementReport;
            AgreementReportAttachment.fileName    = "AgreementReport.pdf";
            AgreementReportAttachment.contentType = "application/pdf";

            return(AgreementReportAttachment);
        }
예제 #4
0
    private string _Subject; //主题

    #endregion Fields

    #region Constructors

    public MailMessage()
    {
        _Recipients = new ArrayList();        //收件人列表
        _Attachments = new MailAttachments(); //附件
        _BodyFormat = MailFormat.HTML;        //缺省的邮件格式为HTML
        _Priority = MailPriority.Normal;
        _Charset = "GB2312";
    }
예제 #5
0
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                MailMessage message = new MailMessage();
                SmtpClient  smtp    = new SmtpClient();
                if (string.IsNullOrEmpty(FromEmailAddress.Get(context)))
                {
                    message.From = new MailAddress(SMTP_Email.Get(context));
                }
                else
                {
                    message.From = new MailAddress(FromEmailAddress.Get(context));
                }


                foreach (string emailid in ToEmailAddress.Get(context).Trim().Split(';'))
                {
                    message.To.Add(new MailAddress(emailid));
                }

                if (!string.IsNullOrEmpty(CCEmailAddress.Get(context)))
                {
                    foreach (string emailid in CCEmailAddress.Get(context).Trim().Split(';'))
                    {
                        message.CC.Add(new MailAddress(emailid));
                    }
                }

                if (!string.IsNullOrEmpty(BccEmailAddress.Get(context)))
                {
                    foreach (string emailid in BccEmailAddress.Get(context).Trim().Split(';'))
                    {
                        message.Bcc.Add(new MailAddress(emailid));
                    }
                }


                message.Subject    = Subject.Get(context).Trim();
                message.IsBodyHtml = IsBodyHtml.Get(context); //to make message body as html
                message.Body       = Body.Get(context).Trim();

                Console.WriteLine("----------------------");


                if (MailAttachments.Get(context) != null)
                {
                    Console.WriteLine("Number of Attachments: " + MailAttachments.Get(context).Count.ToString());
                    foreach (string file in MailAttachments.Get(context))
                    {
                        message.Attachments.Add(new Attachment(file));
                    }
                }


                smtp.Port                  = Convert.ToInt32(SMTP_Port.Get(context));
                smtp.Host                  = SMTP_Server.Get(context).Trim();
                smtp.EnableSsl             = EnableSsl.Get(context);
                smtp.UseDefaultCredentials = false;
                smtp.Credentials           = new System.Net.NetworkCredential(SMTP_Email.Get(context), SMTP_password.Get(context));
                smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                smtp.Send(message);
                IsSuccess.Set(context, true);
                Result.Set(context, string.Empty);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.Message + "--" + e.Source);
                IsSuccess.Set(context, false);
                Result.Set(context, "Error: " + e.Message);
            }
        }