public static bool SendTheEmail()
        {
            bool _success = false;

            //  The mailman object is used for sending and receiving email.
            Chilkat.MailMan _mailman = new Chilkat.MailMan();

            _success = _mailman.UnlockComponent("SCOTTGMAILQ_ZpcR8r2N6R7a");

            if (_success != true)
            {
                //Common.Log(_mailman.LastErrorText);
                return false;
            }

            _mailman.SmtpHost = _smtpHost;

            if (_smtpPort > 0)
            {
                _mailman.SmtpPort = _smtpPort;
            }

            if (_isSSL)
            {
                _mailman.SmtpSsl = true;
            }


            _mailman.SmtpAuthMethod = "LOGIN";

            //ntlmDomain: ucfs.org
            //ntlmUsername: reminders
            //ntlmpassword: @ucfs*1

            _mailman.SmtpLoginDomain = "ucs-domain";
            _mailman.SmtpUsername = "******";
            _mailman.SmtpPassword = "******";



            //  Set the SMTP login/password (if required)
            //SmtpUsername
            //_mailman.SmtpLoginDomain = "ucfs.org";
            //_mailman.SmtpUsername = _smtpHostUserName;
            //_mailman.SmtpPassword = _smtpHostPassword;

            //  Create a new email object
            Chilkat.Email _email = new Chilkat.Email();

            _email.Subject = _emailSubject;

            if (_isHTML)
            {
                _email.SetHtmlBody(_emailBody);
            }
            else
            {
                _email.Body = _emailBody;
            }
            _email.FromName = _emailFromFriendlyName;
            _email.FromAddress = _emailFrom;
            _email.AddTo(_emailToFriendlyName, _emailTo);

            if (_attachment.Length > 0)
            {
                //message.Attachments.Add(new System.Net.Mail.Attachment(_attachment1));
            }

            //  Call SendEmail to connect to the SMTP server and send.
            //  The connection (i.e. session) to the SMTP server remains
            //  open so that subsequent SendEmail calls may use the
            //  same connection.
            _success = _mailman.SendEmail(_email);


            if (_success)
            {
                //Common.Log(" email was successful");
                return true;
            }
            else
            {

                string ss = _mailman.LastErrorText;
                Console.WriteLine(ss);
                Console.Write(_mailman.SmtpSessionLog);
                //Common.Log(dr.GetString(2) + " email was not successful");
                return false;
            }
        }
        public static bool SendAnEmail()
        {
            bool _success = false;

            //  The mailman object is used for sending and receiving email.
            Chilkat.MailMan _mailman = new Chilkat.MailMan();

            _success = _mailman.UnlockComponent("SCOTTGMAILQ_ZpcR8r2N6R7a");

            if (_success != true)
            {
                //Common.Log(_mailman.LastErrorText);
                return false;
            }

            if (_isSSL)
            {
                _mailman.SmtpSsl = true;
            }

            _mailman.SmtpHost = _smtpHost;

            if (_smtpPort > 0)
            {
                _mailman.SmtpPort = _smtpPort;
            }

            //  Set the SMTP login/password (if required)
            _mailman.SmtpUsername = _smtpHostUserName;

            _mailman.SmtpPassword = _smtpHostPassword;

            //  Create a new email object
            Chilkat.Email _email = new Chilkat.Email();

            _email.Subject = _emailSubject;

            if (_isHTML)
            {
                _email.SetHtmlBody(_emailBody);
            }
            else
            {
                _email.Body = _emailBody;
            }
            _email.FromName = _emailFromFriendlyName;
            _email.FromAddress = _emailFrom;

            _email.AddTo(_emailToFriendlyName, _emailTo);

            if (_attachment.Length > 0)
            {
                //message.Attachments.Add(new System.Net.Mail.Attachment(_attachment1));
            }

            //  Call SendEmail to connect to the SMTP server and send.
            //  The connection (i.e. session) to the SMTP server remains
            //  open so that subsequent SendEmail calls may use the
            //  same connection.
            _success = _mailman.SendEmail(_email);


            if (_success)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public static bool SendAnEmail()
        {
            bool success = false;

            //  The mailman object is used for sending and receiving email.
            Chilkat.MailMan mailman = new Chilkat.MailMan();

            success = mailman.UnlockComponent("SCOTTGMAILQ_ZpcR8r2N6R7a");

            if (success != true)
            {
                //Common.Log(_mailman.LastErrorText);
                return false;
            }

            if (isSsl)
            {
                mailman.SmtpSsl = true;
            }

            mailman.SmtpHost = smtpHost;

            if (smtpPort > 0)
            {
                mailman.SmtpPort = smtpPort;
            }

            //  Set the SMTP login/password (if required)
            mailman.SmtpUsername = smtpHostUserName;

            mailman.SmtpPassword = smtpHostPassword;

            //  Create a new email object
            Chilkat.Email email = new Chilkat.Email();

            email.Subject = emailSubject;

            if (isHtml)
            {
                email.SetHtmlBody(emailBody);
            }
            else
            {
                email.Body = emailBody;
            }
            email.FromName = emailFromFriendlyName;
            email.FromAddress = emailFromName;

            email.AddTo(emailToFriendlyName, emailToName);

            if (attachment.Length > 0)
            {
                //message.Attachments.Add(new System.Net.Mail.Attachment(_attachment1));
            }

            //  Call SendEmail to connect to the SMTP server and send.
            //  The connection (i.e. session) to the SMTP server remains
            //  open so that subsequent SendEmail calls may use the
            //  same connection.
            success = mailman.SendEmail(email);

            if (success)
            {
                return true;
            }
            else
            {
                Console.WriteLine(mailman.LastErrorText);
                return false;
            }
        }
    protected bool InstantEmail_RefundReport()
    {
        #region Chilkat MailMan
        using (Chilkat.MailMan mailman = new Chilkat.MailMan())
        {
            mailman.UnlockComponent("SGREENWOODMAILQ_FuY9K2d92R8F");
            mailman.SmtpHost = Connection.GetSmtpHost();
            #region Chilkat Email
            using (Chilkat.Email email = new Chilkat.Email())
            {
                int      tzOffSet = (DateTime.Now.IsDaylightSavingTime()) ? -4 : -5;
                DateTime dt       = DateTime.Parse(CreateDate.Text);
                DateTime dtNow    = DateTime.UtcNow;
                email.AddHeaderField("X-Priority", "1 (High)");
                email.Subject = "ARC Portal - Refund Report";
                email.AddHeaderField("DataExchange-Automated", "LMS_JobNotice JobID:03");
                email.AddHeaderField("Portal-Automated", "Script-ARCRR");

                String emailPath = "emails/";
                String emailFile = "portal_arc_refund_processed.html";
                String htmlBody  = "";

                //System.IO.StreamReader rdr = new StreamReader(Server.MapPath("~") + emailPath + emailFile);
                System.IO.StreamReader rdr = new StreamReader(Server.MapPath(emailPath + emailFile));
                htmlBody = rdr.ReadToEnd();
                rdr.Close();
                rdr.Dispose();

                #region Populate Lead Email Fields
                htmlBody = htmlBody.Replace("{agent_name}", Page.User.Identity.Name);
                htmlBody = htmlBody.Replace("{attempt_on}", " at " + dtNow.ToString("MM/dd/yyyy HH:mm:ss") + " - UTC");

                htmlBody = htmlBody.Replace("{refund_type}", RefundType.Value);
                htmlBody = htmlBody.Replace("{callid}", lblCallID.Text);
                htmlBody = htmlBody.Replace("{donation_date}", dt.ToString("MM/dd/yyyy HH:mm:ss"));
                htmlBody = htmlBody.Replace("{donationccinfoid}", lblExternalID.Text);
                htmlBody = htmlBody.Replace("{refund_status}", rplDecision.Text);
                htmlBody = htmlBody.Replace("{refund_reason}", refundReason.Text);

                htmlBody = htmlBody.Replace("{amount_donation}", AmountOriginal.Value);
                htmlBody = htmlBody.Replace("{amount_refund}", Amount.Text);
                htmlBody = htmlBody.Replace("{first_name}", FirstName.Text);
                htmlBody = htmlBody.Replace("{last_name}", LastName.Text);
                htmlBody = htmlBody.Replace("{card_num}", CardNumber.Text);

                htmlBody = htmlBody.Replace("{refund_message}", msgRefund);


                #endregion Populate Lead Email Fields
                #region Populate Standard Email Fields
                htmlBody = htmlBody.Replace("{script_time}", dtNow.ToString());
                if (DateTime.Now.IsDaylightSavingTime())
                {
                    htmlBody = htmlBody.Replace("{script_timezone}", String.Format("GMT {0} {1}", tzOffSet, "Eastern Daylight Time"));
                }
                else
                {
                    htmlBody = htmlBody.Replace("{script_timezone}", String.Format("GMT {0} {1}", tzOffSet, "Eastern Standard Time"));
                }
                #endregion Populate Standard Email Fields

                email.SetHtmlBody(htmlBody);
                if (Connection.GetConnectionType() == "Local")
                {
                    email.AddTo("Pehuen Test 1", "*****@*****.**");
                    email.AddTo("Carrie Stevenson", "*****@*****.**");
                }
                else
                {
                    email.AddTo("Pehuen ARC", "*****@*****.**");
                    email.AddTo("Carrie Stevenson", "*****@*****.**");
                    //email.AddCC("MIS", "*****@*****.**");
                    //email.AddBcc("Pehuen Scripts", "*****@*****.**");
                }
                email.BounceAddress = "*****@*****.**";
                email.FromName      = "ARC Portal";
                email.FromAddress   = "*****@*****.**";
                email.ReplyTo       = "*****@*****.**";
                bool success;
                success = mailman.SendEmail(email);
                if (success)
                {
                    // Update the action
                    return(true);
                }
                else
                {
                    // Do not update the action, the system will pick it up again
                    return(false);
                }
            }
            #endregion Chilkat Email
        }
        #endregion Chilkat MailMan
    }
Exemple #5
0
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="SmtpServer"></param>
        /// <param name="SmtpPort"></param>
        /// <param name="AccountMail"></param>
        /// <param name="AccountPwd"></param>
        /// <param name="FromName"></param>
        /// <param name="To"></param>
        /// <param name="CC"></param>
        /// <param name="Bcc"></param>
        /// <param name="Subject"></param>
        /// <param name="Body"></param>
        /// <param name="attachmentList"></param>
        /// <param name="Priority"></param>
        /// <param name="IsUseCredentials"></param>
        /// <param name="MainEncoding"></param>
        /// <param name="isHtml"></param>
        /// <param name="IsSSL"></param>
        /// <returns></returns>
        public static bool SendMailEx(string SmtpServer, int SmtpPort, string AccountMail, string AccountPwd, string FromName, string To, string CC, string Bcc, string Subject, string Body, IList <string> attachmentList, int Priority, bool IsUseCredentials, string MainEncoding, bool isHtml, bool IsSSL)
        {
            //过滤掉邮件帐号中的@以及域名
            if (AccountMail.Contains("@"))
            {
                AccountMail = AccountMail.Substring(0, AccountMail.IndexOf("@"));
            }
            //获取发件人邮箱
            string FromMail = string.Empty;

            if (SmtpServer.Contains(';'))
            {
                string[] SmtpServers = SmtpServer.Split(';');
                SmtpServer = SmtpServers[0];
                FromName   = AccountMail + "@" + SmtpServers[1].Substring(SmtpServers[1].IndexOf('.') + 1, SmtpServers[1].Length - SmtpServers[1].IndexOf('.') - 1);
            }
            else
            {
                FromMail = AccountMail + "@" + SmtpServer.Substring(SmtpServer.IndexOf('.') + 1, SmtpServer.Length - SmtpServer.IndexOf('.') - 1);
            }

            string ToName = To.Substring(0, To.IndexOf("@"));

            Chilkat.MailMan mailman = new Chilkat.MailMan();
            bool            success = mailman.UnlockComponent("MAILT34MB34N_6ADE5E140UIY");

            if (success != true)
            {
                return(false);
            }
            //设置SMTP服务器
            mailman.SmtpHost = SmtpServer;
            mailman.SmtpSsl  = IsSSL;
            mailman.SmtpPort = SmtpPort;

            //设置SMTP服务器登录信息
            mailman.SmtpUsername = AccountMail;
            mailman.SmtpPassword = AccountPwd;

            //创建一个Email对象
            Chilkat.Email email = new Chilkat.Email();
            email.Subject = Subject;
            email.Body    = Body;
            email.SetHtmlBody(Body);
            if (attachmentList != null)
            {
                // 附件
                foreach (string attachment in attachmentList)
                {
                    email.AddFileAttachment(attachment);
                }
            }
            email.From = "" + FromName + " <" + FromMail + ">";
            email.AddTo("" + ToName + "", To);

            success = mailman.SendEmail(email);
            mailman.CloseSmtpConnection();
            if (success != true)
            {
                return(false);
            }
            return(success);
        }
Exemple #6
0
    protected void ForgotPassword_Email(String key, DateTime expire, String rtr_Name, String rtr_Email)
    {
        using (Chilkat.MailMan mailman = new Chilkat.MailMan())
        {
            //mailman.UnlockComponent("SGREENWOODMAILQ_FuY9K2d92R8F");
            //mailman.SmtpHost = Connection.GetSmtpHost();

            mailman.UnlockComponent("SGREENWOODMAILQ_FuY9K2d92R8F");
            mailman.SmtpHost     = Connection.SmtpHost();
            mailman.SmtpPort     = Int32.Parse(Connection.SmtpPort());
            mailman.SmtpUsername = Connection.SmtpUsername();
            mailman.SmtpPassword = Connection.SmtpPassword();
            mailman.StartTLS     = true;

            using (Chilkat.Email email = new Chilkat.Email())
            {
                email.Subject = "Greenwood & Hall Portal - Password Reset";

                String openEmail = Server.MapPath(".") + @"\emails\portal_email_password_reminder.html";

                System.IO.StreamReader rdr = new System.IO.StreamReader(System.IO.File.OpenRead(openEmail));
                String htmlBody            = rdr.ReadToEnd(); rdr.Close(); rdr.Dispose();
                String resetLink           = "https://portal.greenwoodhall.com/offline/resetting.aspx?k=" + key;
                htmlBody = htmlBody.Replace("{ResetLink}", resetLink);

                //{ResetLink}
                //{Expire_Date}
                htmlBody = htmlBody.Replace("{Expire_Date}", expire.ToString("MM/dd/yyyy"));
                //{Expire_Time}
                htmlBody = htmlBody.Replace("{Expire_Time}", expire.ToString("HH:mm:ss"));
                //{Expire_Zone}
                htmlBody = htmlBody.Replace("{Expire_Zone}", "PST");
                //{RequestTime}
                htmlBody = htmlBody.Replace("{RequestTime}", DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"));
                //{RequestIP} myIP
                htmlBody = htmlBody.Replace("{RequestIP}", Connection.userIP());
                //{ScriptTimeZone}
                htmlBody = htmlBody.Replace("{ScriptTimeZone}", "PST");

                email.SetHtmlBody(htmlBody);
                //email.AddTo("Pehuen Test", "*****@*****.**");
                email.AddTo(rtr_Name, rtr_Email);

                email.BounceAddress = "*****@*****.**";
                email.FromName      = "Greenwood & Hall Portal";
                email.FromAddress   = "*****@*****.**";
                email.ReplyTo       = "*****@*****.**";
                bool success;
                success = mailman.SendEmail(email);
                if (success)
                {
                    Label2.Text += "<br />Email Sent";
                    //Label2.Text += "<br />" + mailman.LastSmtpStatus;

                    lblLoginMessage.Text  = Label2.Text;
                    lblLoginMessage.Text += "<br />Please check your inbox within a few minutes for a link to reset your password.";

                    Panel1.Visible = true;
                    Panel2.Visible = false;
                }
                else
                {
                    Label2.Text += "<br />Email Failed, internal server error, please try again.";
                }
                //Label2.Text += "<br />" + Connection.GetSmtpHost();
                //Label2.Text += "<br />" + DateTime.Now.ToString("MM/dd/yyyy");
                //Label2.Text += "<br />" + DateTime.Now.ToString("HH:mm:ss");
            }
        }
    }