当前位置: 首页>>代码示例>>C#>>正文


C# EmailMessage.Send方法代码示例

本文整理汇总了C#中EmailMessage.Send方法的典型用法代码示例。如果您正苦于以下问题:C# EmailMessage.Send方法的具体用法?C# EmailMessage.Send怎么用?C# EmailMessage.Send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EmailMessage的用法示例。


在下文中一共展示了EmailMessage.Send方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ButtonRecoverPassword_Click

    protected void ButtonRecoverPassword_Click(object sender, EventArgs e)
    {
        string emailAddress = TextBox1.Text;
        // Get username from email
        string username = Utils.GetUsernameFromEmail(TextBox1.Text);
        if (String.IsNullOrEmpty(username))
        {
            LabelStatus.Text = "Email Address Not Found. Please Register.";
        }
        else
        {
            MembershipUser mu = Membership.GetUser(username);
            String newPassword = mu.ResetPassword();

            var msg = new EmailMessage(true, false);
            msg.Logging = false;
            msg.LogOverwrite = false;
            msg.LogPath = Context.Server.MapPath(String.Empty) + "\\App_Data\\EmailPasswordRecovery.log";
            msg.FromAddress = Utils.GetServiceEmailAddress();
            msg.To = emailAddress;
            msg.Subject = "Your New Password For http://www.siliconvalley-codecamp.com";

            if (msg.Server.Equals("smtp.gmail.com"))
            {
                var ssl = new AdvancedIntellect.Ssl.SslSocket();
                msg.LoadSslSocket(ssl);
                msg.Port = 587;
            }

            var sb = new StringBuilder();
            sb.AppendLine(
                String.Format("Please log in to your codecamp account ({0}) with the new password: {1}",
                              username, newPassword));
            sb.AppendLine(" ");
            sb.AppendLine("We suggest that after you log in, you change your password to something");
            sb.AppendLine("you will likely remember.  We store your password in an encrypted format which is");
            sb.AppendLine("why we are unable to send you your original password.");
            sb.AppendLine(" ");
            sb.AppendLine("We are looking forward to seeing you!");
            sb.AppendLine(" ");
            sb.AppendLine("Best Regards,");
            sb.AppendLine("The Code Camp Volunteers");
            sb.AppendLine("http://www.siliconvalley-codecamp.com");

            msg.Body = sb.ToString();

            msg.Send();
            LabelStatus.Text = "Password Sent to your registered email account.";
        }
    }
开发者ID:suwatch,项目名称:svcodecampweb,代码行数:50,代码来源:PasswordIssues.aspx.cs

示例2: assignMenuItem_Click

        private void assignMenuItem_Click(object sender, EventArgs e)
        {
            if (taskListBox.SelectedIndex >= 0)
            {
                ChooseContactDialog dialog = new ChooseContactDialog();
                dialog.RestrictContacts = "[Department] = \"Field\"";
                dialog.Title = "Assign To";

                if (dialog.ShowDialog() == DialogResult.OK)
                {

                    #region Send Email to Contact

                    // ... ali prvo provjeri ima li e-adrese!
                    if (String.IsNullOrEmpty(dialog.SelectedContact.Email1Address))
                    {
                        MessageBox.Show("Assignee lacks e-address.");
                        return;
                    }

                    EmailMessage email = new EmailMessage();
                    email.To.Add(new Recipient(dialog.SelectedContact.Email1Address));

                    Task task = (Task)taskListBox.SelectedItem;

                    email.Subject = string.Format("Task Assigned: {0}", task.Subject);
                    email.BodyText = task.Body;

                    // Provjeriti postoji li fotka.
                    if (!String.IsNullOrEmpty((string)task.Properties["Photo"]))
                    {
                        email.Attachments.Add(new Attachment((string)task.Properties["Photo"]));
                    }
                    email.Send("ActiveSync");

                    #endregion

                    #region Complete task

                    task.Complete = true;
                    task.Update();

                    taskListBox.Items.RemoveAt(taskListBox.SelectedIndex);

                    #endregion

                    #region Call Engineer

                    if (MessageBox.Show(
                        string.Format("Call {0} now?", dialog.SelectedContactName),
                        "Call Ahead",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        Phone phone = new Phone();
                        phone.Talk(dialog.SelectedContact.BusinessTelephoneNumber);
                    }

                    #endregion

                }
            }
        }
开发者ID:Brumiko,项目名称:WinMobSession1,代码行数:64,代码来源:Main.cs

示例3: SendMailConfirmation

        private void SendMailConfirmation(string contactEmail, string company, int id)
        {
            var sb = new StringBuilder();
               sb.AppendLine("email: " + contactEmail);
               sb.AppendLine("company:" + company);
               sb.AppendLine("url: " + "http://siliconvalley-codecamp.com/rest/SponsorRequest/" + id.ToString(CultureInfo.InvariantCulture));

               var msg = new EmailMessage(true, false);
               int portNumber = Convert.ToInt32(ConfigurationManager.AppSettings["EmailMessage.Port"]);
               msg.Port = portNumber;

               if (msg.Server.Equals("smtp.gmail.com"))
               {
               var ssl = new AdvancedIntellect.Ssl.SslSocket();
               msg.LoadSslSocket(ssl);
               msg.Port = 587;
               }

               msg.CharSet = "iso-8859-1";
               msg.Logging = true;
               msg.LogInMemory = true;
               msg.LogOverwrite = false;
               //msg.LogPath = logFile;
               msg.FromAddress = "[email protected]";
               msg.To = "[email protected]";
               msg.Subject = "Sponsorship Email From: " + company + " " + contactEmail;
               msg.Body = sb.ToString();

               try
               {
               msg.Send(true, false);
               }
               catch (Exception)
               {

              // throw;
               }

               var str = msg.Log;
        }
开发者ID:suwatch,项目名称:svcodecampweb,代码行数:40,代码来源:SponsorRequestController.cs

示例4: send

        public bool send(string sImagePath)
        {
            if (account == null)
                return false;
            try
            {
                eMail = new EmailMessage();
                rcp = new Recipient(_to);
                eMail.To.Add(rcp);
                eMail.Subject = "Visitenkarten LogiMAT";
                eMail.BodyText = "LogiMat " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "\r\nsent from eMDI2Mail";

                attachement = new Attachment(sImagePath);
                eMail.Attachments.Add(attachement);
                eMail.Send(account);
                //account.Send(eMail);
                if (this._syncImmediately)
                {
                    if (this.account != null)
                        Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.Synchronize(this.account);
                }
                return true;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception in send(): " + ex.Message);
            }
            return false;
        }
开发者ID:hjgode,项目名称:eMdiMail,代码行数:29,代码来源:sendMail.cs

示例5: SendMail

 /// <summary>
 /// Does the actual send action for the emails, using the System.Web.Mail namespace
 /// </summary>
 /// <param name="mail"></param>
 /// <param name="onlyTestDontSendMail"></param>
 /// <returns></returns>
 internal bool SendMail(EmailMessage mail, bool onlyTestDontSendMail)
 {
     //don't send mail if localhost is set to smtp-server (probably in development enviroment)
     // 20051219 SC: Comment above is sound, but there is no test for it
     if (onlyTestDontSendMail == false)
     {
         // It returns true if successfull
         return mail.Send();
     }
     return false;
 }
开发者ID:tsolbjor,项目名称:Newsletter,代码行数:17,代码来源:MailSenderAdvIntellect.cs

示例6: SendEmailToSpeakerJustBeforeEvent

    private void SendEmailToSpeakerJustBeforeEvent(string userFirstName, string userLastName, string email, string sessionTitle, string tweet)
    {
        var sb = new StringBuilder();

        sb.AppendLine(String.Format("Hi {0} {1} (Code Camp Speaker)", userFirstName, userLastName));
        sb.AppendLine(" ");
        sb.AppendLine(String.Format("Your Session {0} Has Been Tweeted With the agenda info!", sessionTitle));
        sb.AppendLine(" ");
        sb.AppendLine("You can now see your session on the Silicon Valley Code Camp Twitter Feed.  That feed can be found");
        sb.AppendLine("at the url: http://twitter.com/sv_code_camp .  Please subscribe to the twitter feed as well as ReTweet");
        sb.AppendLine("it so other will know about it.  Also, please note our Twitter hash tag included in that tweet is #svcc .");
        sb.AppendLine("If you do not have hash tags or your twitter handle (if you have one) in the tweet, please add them by editing your session.");
        sb.AppendLine(" ");

        sb.AppendLine("Thanks for speaking at code camp!  See you very soon.  Feel free to respond to this email if you have any questions.");
        sb.AppendLine(" ");
        sb.AppendLine("Regards,");
        sb.AppendLine("Your Code Camp Team");
        sb.AppendLine("http://siliconvalley-codecamp.com");

        try
        {
            var msg = new EmailMessage(true, false)
            {
                Logging = true,
                LogOverwrite = false,
                LogPath = MapPath(string.Empty) + "\\App_Data\\TwitterSend.log",
                FromAddress = Utils.GetServiceEmailAddress(),
                ReplyTo = Utils.GetServiceEmailAddress(),
                To = email,
                Subject = String.Format("Your Silicon Valley Code Camp Session Has Been Tweeted!"),
                Body = sb.ToString()
            };

            if (msg.Server.Equals("smtp.gmail.com"))
            {
                var ssl = new AdvancedIntellect.Ssl.SslSocket();
                msg.LoadSslSocket(ssl);
                msg.Port = 587;
            }
            if (!testMode)
            {
                msg.Send();
            }

        }
        catch (Exception)
        {

        }
    }
开发者ID:suwatch,项目名称:svcodecampweb,代码行数:51,代码来源:TwitterPost.aspx.cs

示例7: GenerateMails

    public void GenerateMails()
    {
        lock (Utils.MailLocker)
        {
            int delayPerEmailMilliSeconds = 0;
            if (emailsPerHour != 0)
            {
                delayPerEmailMilliSeconds = 3600000 / emailsPerHour;
            }

            DateTime startTime = DateTime.Now;
            var sbLog = new StringBuilder();
            sbLog.AppendLine("----------------START-------------------------------" + DateTime.Now);
            sbLog.AppendLine(String.Format("Email Delay in MilliSeconds {0}, Repeat Each Email: {1}",
                                           delayPerEmailMilliSeconds, repeatEachEmail));
            sbLog.AppendLine("Message Subject: " + subject);
            sbLog.AppendLine("Message From: " + fromEmail);
            sbLog.AppendLine("Message Body: " + body);

            var msg = new EmailMessage(true, false);
            int portNumber =  Convert.ToInt32(ConfigurationManager.AppSettings["EmailMessage.Port"].ToString());
            msg.Port = portNumber;

            if (msg.Server.Equals("smtp.gmail.com"))
            {
                var ssl = new AdvancedIntellect.Ssl.SslSocket();
                msg.LoadSslSocket(ssl);
                msg.Port = 587;
            }

            // using for instead of foreach cause it's easier to track start and end of list
            for (int i = 0; i < toEmailList.Count; i++)
            {
                try
                {
                    var cacheName = (string)cache[Utils.CacheMailCancelFlag];
                    if (!string.IsNullOrEmpty(cacheName))
                    {
                        if (((string)cache[Utils.CacheMailCancelFlag]).Equals("true"))
                        {
                            sbLog.AppendLine("Mail Send Cancelled By User");
                            cache[Utils.CacheMailSentStatusName] = "Mail Send Cancelled By User";
                            break;
                        }
                    }

                    msg.CharSet = "iso-8859-1";
                    msg.Logging = true;
                    msg.LogOverwrite = false;
                    msg.LogPath = logFile;
                    msg.FromAddress = fromEmail;
                    msg.To = toEmailList[i];
                    msg.Subject = subject;
                    string PKIDStr = string.Empty;
                    if (DictionaryOfPKIDsByEmail.ContainsKey(toEmailList[i]))
                    {
                        PKIDStr = DictionaryOfPKIDsByEmail[toEmailList[i]];
                    }

                    msg.Body = !String.IsNullOrEmpty(PKIDStr) ? body.Replace("{PKID}", PKIDStr) : body;
                }
                catch (Exception)
                {
                  // just skip any bad email here
                }

                for (int repeatCnt = 0; repeatCnt < repeatEachEmail;repeatCnt++ )
                {
                    try
                    {
                        if (i == 0 && toEmailList.Count == 1)
                        {
                            msg.Send();
                        }
                        else if (i == 0)
                        {
                            msg.Send(true, false);
                        }
                        else if (i == toEmailList.Count - 1)
                        {
                            msg.Send(false, true);
                        }
                        else
                        {
                            msg.Send(false, false);
                        }
                        string mailStatus = i + "Success Send To: " + msg.To;
                        // should really add with expiration but this is pretty small so not worring about it
                        cache[Utils.CacheMailSentStatusName] = mailStatus;
                        sbLog.AppendLine(mailStatus);
                        Thread.Sleep(delayPerEmailMilliSeconds);
                    }
                    catch (Exception eError)
                    {
                        sbLog.AppendLine(i + ":" + eError);
                    }
                }
            }

            DateTime stopTime = DateTime.Now;
//.........这里部分代码省略.........
开发者ID:suwatch,项目名称:svcodecampweb,代码行数:101,代码来源:EmailerAdmin.aspx.cs

示例8: CaptchaUltimateControl1_Verified

    //CaptchaUltimateControl1_Verified
    protected void CaptchaUltimateControl1_Verified(object sender, EventArgs e)
    {
        string completionMessage = string.Empty;
        string sessionNamex = GetFromCaptchaControl("SessionNameID");
        string presenterName = GetFromCaptchaControl("PresenterNameID");
        string textBoxMessageString = GetFromCaptchaControl("TextBoxMessageID");

        var sb = new StringBuilder();

        //sb.AppendLine(String.Format("To: {0} ", presenterName ?? string.Empty));
        //sb.AppendLine(String.Format("From: {0} Sent Through Silicon Valley Code Camp", userEmail ?? string.Empty));
        //sb.AppendLine(String.Format("Subject: Your Session {0}", sessionNamex ?? string.Empty));
        sb.AppendLine(" ");
        sb.AppendLine(textBoxMessageString ?? string.Empty);
        sb.AppendLine(" ");
        sb.AppendLine("------------------------------------------------------- ");
        sb.AppendLine("Note From Code Camp:");
        sb.AppendLine(" ");
        sb.AppendLine(" ");
        sb.AppendLine(String.Format("This note was generated by user {0} pressing the 'Email Speaker Button' on your session: ", attendeeEmail));
        sb.Append(sessionTitle);
        sb.Append(" ");
        sb.Append(sessionURL);
        sb.AppendLine(" ");
        sb.AppendLine(" ");

        // todo: this needs to be person requesting
        sb.Append(String.Format("{0} {1} at email {2} does not have your email.  Please do not press the reply button. ",
            attendeeFirstName,attendeeLastName,attendeeEmail));

        sb.Append("To reply to this person, use the users ");
        sb.Append(String.Format("email address {0}.",attendeeEmail));
        sb.AppendLine(" ");
        sb.AppendLine(" ");
        sb.Append(
            "If you do not want user to be able to send you emails, log into your code camp account, choose 'My Profile' on the left sidebar, and check the box 'Do Not Display Email Speaker On My Session'. ");
        sb.AppendLine(" ");
        sb.AppendLine(" ");
        sb.AppendLine("Thanks for speaking at Silicon Valley Code Camp!");

        try
        {
            var msg = new EmailMessage(true, false)
                          {
                              Logging = true,
                              LogOverwrite = false,
                              LogPath = MapPath(string.Empty) + "\\App_Data\\SpeakerSend.log",
                              FromAddress = Utils.GetServiceEmailAddress(),
                              ReplyTo = attendeeEmail,
                              To = speakerEmail,
                              Subject =
                                  String.Format("Code Camp Email From Attendee: {0} {1} Email: {2} on your Session",
                                                userFirstName, userLastName, attendeeEmail),
                              Body = sb.ToString()
                          };

            if (msg.Server.Equals("smtp.gmail.com"))
            {
                var ssl = new AdvancedIntellect.Ssl.SslSocket();
                msg.LoadSslSocket(ssl);
                msg.Port = 587;
            }
            msg.Send();

            SetCaptchaControlLabel("LabelStatus", "Message Sent Successfully");
            HyperLinkHome.Visible = true;

        }
        catch (Exception ee)
        {
            SetCaptchaControlLabel("LabelStatus", "Message Did Not Send Correctly.  Sorry  Please email [email protected] for more help." + ee);
        }
    }
开发者ID:suwatch,项目名称:svcodecampweb,代码行数:74,代码来源:SpeakerMailTo.aspx.cs

示例9: PostForgotPassword

        public HttpResponseMessage PostForgotPassword(AttendeesResult attendeesResult)
        {
            HttpResponseMessage response;

            string usernameOrEmail = attendeesResult.Username;


            string username = Utils.GetUsernameFromEmail(usernameOrEmail);
            if (String.IsNullOrEmpty(username))
            {
                string goodEmail = Utils.GetEmailFromUsername(usernameOrEmail);
                username = Utils.GetUsernameFromEmail(goodEmail);
            }

            if (String.IsNullOrEmpty(username))
            {
                response =
                    Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed,
                                                "Name not found as either username or email.  Please register as new attendee");
            }
            else
            {
                var attendeeRec = AttendeesManager.I.Get(new AttendeesQuery {Username = username}).FirstOrDefault();
                if (attendeeRec == null)
                {
                    throw new ApplicationException("attendeeRec could not be loaded");
                }
                MembershipUser mu = Membership.GetUser(username);
                if (mu == null)
                {
                    throw new ApplicationException("MembershipUser mu not found");
                }
                var newPassword = mu.ResetPassword();
                var msg = new EmailMessage(true, false)
                    {
                        Logging = false,
                        LogOverwrite = false,
                        //LogPath = Context.Server.MapPath(String.Empty) + "\\App_Data\\EmailPasswordRecovery.log",
                        FromAddress = Utils.GetServiceEmailAddress(),
                        To = attendeeRec.Email,
                        Subject = "Your New Password For http://www.siliconvalley-codecamp.com"
                    };

                if (msg.Server.Equals("smtp.gmail.com"))
                {
                    var ssl = new AdvancedIntellect.Ssl.SslSocket();
                    msg.LoadSslSocket(ssl);
                    msg.Port = 587;
                }

                var sb = new StringBuilder();
                sb.AppendLine(
                    String.Format("Please log in to your codecamp account ({0}) with the new password: {1}",
                                  username, newPassword));
                sb.AppendLine(" ");
                sb.AppendLine("We suggest that after you log in, you change your password.");
                sb.AppendLine("We store your password in an encrypted format which is");
                sb.AppendLine("why we are unable to send you your original password.");
                sb.AppendLine(" ");
                sb.AppendLine("We are looking forward to seeing you at camp!");
                sb.AppendLine(" ");
                sb.AppendLine("Best Regards,");
                sb.AppendLine("");
                sb.AppendLine("http://www.siliconvalley-codecamp.com");

                msg.Body = sb.ToString();

                try
                {
                    msg.Send();
                    response =
                        Request.CreateResponse(HttpStatusCode.OK, new AttendeesResult()
                            {
                                Email = attendeeRec.Email,
                                Username = attendeeRec.Username,
                                Id = attendeeRec.Id
                            });
                }
                catch (Exception e)
                {
                    response =
                        Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed,
                                                    "We found your account but email could not be delivered to " +
                                                    attendeeRec.Email + " for account " + attendeeRec.Username +
                                                    ".  Please Make a new account or contact [email protected] and we will reset the password for you.");
                }
            }
            return response;
        }
开发者ID:suwatch,项目名称:svcodecampweb,代码行数:89,代码来源:AccountController.cs


注:本文中的EmailMessage.Send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。