SetSmtpCredentials() public method

public SetSmtpCredentials ( string username, string password ) : void
username string
password string
return void
        /// <summary>
        /// Resend any email that has previously been sent and logged. The email to resend is based on the email log ID, so only emails present in the log table can be resent.
        /// </summary>
        /// <param name="logmailID">The email log ID</param>
        /// <param name="recipientEmail">(optioneel) The alternative recipient of the email that will be resent. If left null or empty, the original recipient's emailaddress will be used</param>
        /// <param name="includeCC">Should the email also be sent to the original CC recipients?</param>
        /// <param name="includeBCC">Should the email also be sent to the original CC recipients?</param>
        /// <returns>The log ID of the email that was sent</returns>
        public static int ReSendEmail(int logmailID, string recipientEmail = null, bool includeCC = false, bool includeBCC = false)
        {
            var logMail = LogEmail.Get(logmailID);

            var m = new Email();
            m.To.Add(new MailAddress(recipientEmail ?? logMail.to));
            m.From = new MailAddress(logMail.from);
            if (!String.IsNullOrEmpty(logMail.replyTo))
                m.ReplyToList.Add(new MailAddress(logMail.replyTo));
            if (!String.IsNullOrEmpty(logMail.cc))
                m.CC.Add(new MailAddress(logMail.cc));
            if (!String.IsNullOrEmpty(logMail.bcc))
                m.BCC.Add(new MailAddress(logMail.bcc));
            if (!String.IsNullOrEmpty(logMail.host))
                m.SmtpHost = logMail.host;
            if (!String.IsNullOrEmpty(logMail.userID))
                m.SetSmtpCredentials(logMail.userID, null); // Dit is natuurlijk knudde want zonder het wachtwoord kom je niet ver
            m.Subject = logMail.subject;
            m.Body = logMail.body;
            m.EmailId = logMail.emailID;
            m.AlternativeView = logMail.alternativeView;
            if (!String.IsNullOrEmpty(logMail.attachment))
                foreach (String attachment in logMail.attachment.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                    if (!string.IsNullOrEmpty(attachment)) // redundant
                    {
                        // Is het toevallig een Umbraco Media Node Id?
                        int tmp;
                        if (attachment.All(c => Char.IsDigit(c)))
                        {
                            if (int.TryParse(attachment, out tmp))
                            {
                                // Ah, dat is makkelijk, gewoon het bestand uit Umbraco vissen
                                string filename = Helper.GetUmbracoMediaFile(tmp, true);
                                if (!String.IsNullOrEmpty(filename))
                                    m.Attachments.Add(new Attachment(filename));
                            }
                        }
                        else
                            // Fysiek pad op de schijf
                            m.Attachments.Add(new Attachment(attachment));
                    }
            return m.SendEmail();
        }
        public static void DownloadEmail(int logmailID)
        {
            var logMail = LogEmail.Get(logmailID);

            var m = new Email();
            m.To.Add(new MailAddress(logMail.to));
            m.From = new MailAddress(logMail.from);
            if (!String.IsNullOrEmpty(logMail.replyTo))
                m.ReplyToList.Add(new MailAddress(logMail.replyTo));
            if (!String.IsNullOrEmpty(logMail.cc))
                m.CC.Add(new MailAddress(logMail.cc));
            if (!String.IsNullOrEmpty(logMail.bcc))
                m.BCC.Add(new MailAddress(logMail.bcc));
            if (!String.IsNullOrEmpty(logMail.host))
                m.SmtpHost = logMail.host;
            if (!String.IsNullOrEmpty(logMail.userID))
                m.SetSmtpCredentials(logMail.userID, null); // Dit is natuurlijk knudde want zonder het wachtwoord kom je niet ver
            m.Subject = logMail.subject;
            m.Body = logMail.body;
            m.EmailId = logMail.emailID;
            m.AlternativeView = logMail.alternativeView;
            if (!String.IsNullOrEmpty(logMail.attachment))
                foreach (String attachment in logMail.attachment.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                    if (!string.IsNullOrEmpty(attachment)) // redundant
                    {
                        // Is the string actually an integer?
                        int tmp;
                        if (attachment.All(c => Char.IsDigit(c)))
                        {
                            if (int.TryParse(attachment, out tmp))
                            {
                                // Ah, that's convienent since it's an Umbraco Media Node Id. Try to get the media file from Umbraco
                                string filename = Helper.GetUmbracoMediaFile(tmp, true);
                                if (!String.IsNullOrEmpty(filename))
                                    m.Attachments.Add(new Attachment(filename));
                            }
                        }
                        else
                            // Fysical path on the harddisk
                            m.Attachments.Add(new Attachment(attachment));
                    }

            m._mail.Attachments.Clear();
            foreach (var a in m.Attachments)
            {
                if (a.Stream != null)
                    // Use the supplied stream
                    m._mail.Attachments.Add(new System.Net.Mail.Attachment(a.Stream, a.FileName));
                else
                    // Find the file on the harddisk
                    m._mail.Attachments.Add(new System.Net.Mail.Attachment(a.FileDirectory + a.FileName));
            }

            // Filename in the beowser as "nodename - logId - email"
            string downloadFilename = new Node(m.EmailId).Name + " - " + logmailID.ToString();

            if (m.To != null && m.To.Count > 0)
                downloadFilename += " - " + m.To[0].Address;

            downloadFilename = Helper.SanitizeFilename(downloadFilename);
            Helper.SendMailMessageToBrowser(m._mail, downloadFilename);
        }