コード例 #1
0
        /// <summary>
        /// Application wide convenience email utility.
        /// </summary>
        /// <param name="to"></param>
        /// <param name="subject"></param>
        /// <param name="html"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public static Boolean sendEmail(String to, String subject, String html, String text, String bcc)
        {

            if (!Boolean.Parse(ConfigurationManager.AppSettings["SESEnabled"].ToString())) { return false; }

            SESUtils u = getSESUtils();
            Email e = new Email();


            e.to = new List<String>() { to };

            if (!String.IsNullOrEmpty(bcc))
            {
                String[] bccList = bcc.Split(',').Select(sValue => sValue.Trim()).ToArray();
                e.bcc = new List<String>();
                foreach (String s in bccList)
                {
                    e.bcc.Add(s);
                }
            }

            e.subject = subject;

            e.text = text;
            e.html = html;

            e.returnPath = ConfigurationManager.AppSettings["SESReturnPath"]; // bounces go here
            e.source = ConfigurationManager.AppSettings["SESSource"]; // sender's email address

            u.sendEmail(e);

            return true;
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!this.Posted)
            {
                r = Utility.getSESUtils().listVerifiedEmails();
            } 
            else // process the form post.
            {
                // if not a valid form post, then do nothing else.
                if (!validForm())
                {
                    r = Utility.getSESUtils().listVerifiedEmails();
                    return;
                }

                SESUtils sesUtils = Utility.getSESUtils();

                String[] stringSeparator = new String[] { ";" };

                Email msg = new Email();

                msg.subject = this.Subject;
                msg.to = this.ToAddressesList;

                if (!String.IsNullOrEmpty(this.CcAddresses))
                {
                    msg.cc = this.CcAddressesList;
                }

                if (!String.IsNullOrEmpty(this.BccAddresses))
                {
                    msg.bcc = this.BccAddressesList;
                }

                if (!String.IsNullOrEmpty(this.ReplyToAddresses))
                {
                    msg.replyToAddresses = this.ReplyToAddressesList;
                }

                msg.returnPath = this.ReturnPath; // bounces go here
                msg.source = this.Source; // sender's email address
                msg.html = this.BodyHTML;
                msg.text = this.BodyTEXT;

                sesUtils.sendEmail(msg);

                emailSent = true;

            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            SESUtils sesUtil = new SESUtils("", "");

            Email m = new Email();
            m.text = "text";
            m.html = "html";
            m.to = new List<string>() { "*****@*****.**" };
            m.source = "*****@*****.**";
            m.returnPath = "*****@*****.**";
            m.replyToAddresses = new List<string>() { "*****@*****.**" };
            m.subject = "test";

        }