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


C# MailAddress类代码示例

本文整理汇总了C#中MailAddress的典型用法代码示例。如果您正苦于以下问题:C# MailAddress类的具体用法?C# MailAddress怎么用?C# MailAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: SendHTMLMail

 // Method Which is used to Get HTML File and replace HTML File values with dynamic values and send mail
 public void SendHTMLMail()
 {
     StreamReader reader = new StreamReader(Server.MapPath("~/HTMLPage.htm"));
     string readFile = reader.ReadToEnd();
     string myString = "";
     myString = readFile;
     myString = myString.Replace("$$Admin$$", "Suresh Dasari");
     myString = myString.Replace("$$CompanyName$$", "Dasari Group");
     myString = myString.Replace("$$Email$$", "[email protected]");
     myString = myString.Replace("$$Website$$", "http://www.aspdotnet-suresh.com");
     MailMessage Msg = new MailMessage();
     MailAddress fromMail = new MailAddress("[email protected]");
     // Sender e-mail address.
     Msg.From = fromMail;
     // Recipient e-mail address.
     Msg.To.Add(new MailAddress("[email protected]"));
     // Subject of e-mail
     Msg.Subject = "Send Mail with HTML File";
     Msg.Body = myString.ToString();
     Msg.IsBodyHtml = true;
     string sSmtpServer = "";
     sSmtpServer = "10.2.69.121";
     SmtpClient a = new SmtpClient();
     a.Host = sSmtpServer;
     a.Send(Msg);
     reader.Dispose();
 }
开发者ID:Dashboard-X,项目名称:SendHTMLFileAsMailBody,代码行数:28,代码来源:SendMailwithHtml.aspx.cs

示例2: PrepareHeaders_WithReplyToListSet_AndReplyToHeaderSetManually_ShouldEnforceReplyToListIsSingleton

        public void PrepareHeaders_WithReplyToListSet_AndReplyToHeaderSetManually_ShouldEnforceReplyToListIsSingleton()
        {
            MailAddress m = new MailAddress("[email protected]");
            MailAddress m2 = new MailAddress("[email protected]");
            MailAddress m3 = new MailAddress("[email protected]");

            _message.ReplyToList.Add(m);
            _message.ReplyToList.Add(m2);
            _message.ReplyToList.Add(m3);

            _message.Headers.Add("Reply-To", "[email protected]");

            _message.From = new MailAddress("[email protected]");

            _message.PrepareHeaders(true, false);

            Assert.True(_message.ReplyToList.Count == 3, "ReplyToList did not contain all email addresses");

            string[] s = _message.Headers.GetValues("Reply-To");
            Assert.Equal(1, s.Length);

            Assert.True(s[0].Contains("[email protected]"));
            Assert.True(s[0].Contains("[email protected]"));
            Assert.True(s[0].Contains("[email protected]"));
            Assert.False(s[0].Contains("[email protected]"));

            Assert.Null(_message.ReplyTo);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:28,代码来源:ReplyToListTest.cs

示例3: Send

 public void Send()
 {
     Result = "";
     Success = true;
     try
     {
         // send email
         var senderAddress = new MailAddress(SenderAddress, SenderName);
         var toAddress = new MailAddress(Address);
         var smtp = new SmtpClient
         {
             Host = SmtpServer,
             Port = SmtpPort,
             EnableSsl = true,
             DeliveryMethod = SmtpDeliveryMethod.Network,
             UseDefaultCredentials = false,
             Credentials = new NetworkCredential(senderAddress.Address, Password),
             Timeout = 5000
         };
         smtp.ServicePoint.MaxIdleTime = 2;
         smtp.ServicePoint.ConnectionLimit = 1;
         using (var mail = new MailMessage(senderAddress, toAddress))
         {
             mail.Subject = Subject;
             mail.Body = Body;
             mail.IsBodyHtml = true;
             smtp.Send(mail);
         }
     }
     catch(Exception ex)
     {
         Result = ex.Message + " " + ex.InnerException;
         Success = false;
     }
 }
开发者ID:jaroban,项目名称:Web,代码行数:35,代码来源:Email.cs

示例4: Button1_Click

    //protected void gridView_Load(object sender, EventArgs e)
    //{
    //    for (int i = 0; i < GridView1.Rows.Count; i++)
    //    {
    //        if ((DateTime.Parse(GridView1.Rows[i].Cells[2].Text)) < (DateTime.Parse(DateTime.Today.ToShortDateString())))
    //        {
    //            GridView1.Rows[i].Visible = false;
    //            //GridView1.da
    //        }
    //    }
    //}
    protected void Button1_Click(object sender, EventArgs e)
    {
        MyService.UserWebService uws = new UserWebService();
        uws.Credentials = System.Net.CredentialCache.DefaultCredentials;
        int id = uws.getAppointmentID(Int32.Parse(DropDownList1.SelectedValue), DateTime.Parse(Label1.Text));
        int status = 1;
        uws.makeStudentAppointment(id, sid, txtSubject.Text, DateTime.Parse(DropDownList2.SelectedValue), DateTime.Parse(txtEndtime.Text), status);
        //   SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
        //smtp.UseDefaultCredentials = false;
        //smtp.Credentials = new NetworkCredential("[email protected]","were690vase804");
        //smtp.EnableSsl = true;
        //smtp.Send("[email protected]", "[email protected]", "Appointment", "Appointment Successfull");

        MailAddress mailfrom = new MailAddress("[email protected]");
        MailAddress mailto = new MailAddress("[email protected]");
        MailMessage newmsg = new MailMessage(mailfrom, mailto);

        newmsg.Subject = "APPOINTMENT";
        newmsg.Body = "Appointment Successful";

        //    Attachment att = new Attachment("C:\\...file path");
          //  newmsg.Attachments.Add(att);

        SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
        smtp.UseDefaultCredentials = false;
        smtp.Credentials = new NetworkCredential("[email protected]","were690vase804");
        smtp.EnableSsl = true;
        smtp.Send(newmsg);
        Response.Write(@"<script language='javascript'>alert('Appointment Made and Confirmation has been sent to your mail')</script>");
    }
开发者ID:tkoushik1,项目名称:OnlineAppointmentManagementSystem,代码行数:41,代码来源:makeappointment.aspx.cs

示例5: Retrieve_Password

    public bool Retrieve_Password(string email, string pass)
    {
        string _email = email;
        string _pass = pass;

        try
        {
            //Create the email message

            MailAddress from = new MailAddress("[email protected]");
            MailAddress to = new MailAddress(email.Trim());
            MailMessage mailObj = new MailMessage(from, to);
            mailObj.Subject = "Password Recovery";
            //Create the message body
            mailObj.Body += "<h2>Password recovery request from Weservullc.com</h2><br /> "
                + "<p>Your password is: " + _pass + "</p>";

            mailObj.IsBodyHtml = true;

            //uncomment these lines when loading to GoDaddy Servers.

            SmtpClient smtp = new SmtpClient(SERVER);
            smtp.Send(mailObj);
            mailObj = null;
            return true;
        }
        catch(SmtpException se)
        {
            return false;
        }
    }
开发者ID:scottbeachy,项目名称:SeniorProject,代码行数:31,代码来源:SendMail.cs

示例6: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)
    {
        MailMessage msg = new MailMessage();
        MailAddress mailadd = new MailAddress("[email protected]","Amita Shukla");
        msg.From = mailadd;
        msg.To.Add(new MailAddress(TextBox1.Text));
        msg.Subject = TextBox2.Text;
        msg.Body = TextBox4.Text;
        if (FileUpload1.HasFile)
        {
            msg.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
        }

        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com";
        NetworkCredential nkc = new NetworkCredential("[email protected]", "*******");
        smtp.Credentials = nkc;
        smtp.EnableSsl = true;

        try
        {
            smtp.Send(msg);
            Label5.Text = "Email sent successfully";
        }
        catch(Exception ex)
        {
            Label5.Text = ex.Message;
        }
    }
开发者ID:amita-shukla,项目名称:email,代码行数:29,代码来源:Default.aspx.cs

示例7: Send

    public static void Send(string toEmail, string toTen, string subject, string body, string fromEmail, string fromName)
    {
        var fromAddress = new MailAddress(fromEmail, fromName);
        var toAddress = new MailAddress(toEmail, toTen);

        var smtp = new SmtpClient
        {
            Host = "email-smtp.eu-west-1.amazonaws.com",
            Port = 587,
            EnableSsl = true,
            DeliveryMethod = SmtpDeliveryMethod.Network,
            Credentials = new NetworkCredential("AKIAINTSEWVCFL5UA2MQ", "AuwQb9Mbo72AaPuJMGi0ZBw7ozgxGPtwUei60NuueMWB"),
            Timeout = 20000
        };
        using (var message = new MailMessage(fromAddress, toAddress)
        {
            Subject = subject,
            Body = body,
            BodyEncoding = System.Text.Encoding.UTF8,
            SubjectEncoding = System.Text.Encoding.UTF8,
            IsBodyHtml = true

        })
        {
            try
            {
                smtp.Send(message);
            }
            catch (SmtpException ex)
            {

            }
        }
    }
开发者ID:nhatkycon,项目名称:xetui,代码行数:34,代码来源:SesEmail.aspx.cs

示例8: sendReceipt

    //Now in ppClass_sb.cs
    //get expired permits and reset spots to unoccupied
    //private void _resetSpots()
    //{
    //    //get expired spots
    //    var expiredSpots = objPark.getExpiredPermits(DateTime.Now);
    //    foreach (var spot in expiredSpots)
    //    {
    //       var spotSingle = objPark.getSpotBySpot(spot.spot);
    //    }
    //}
    //Send Email Receiptfd
    protected void sendReceipt(DateTime _timeExp, string _spot)
    {
        //This is the script provided by my hosting to send mail (Source URL: https://support.gearhost.com/KB/a777/aspnet-form-to-email-example.aspx?KBSearchID=41912)
        try
        {
            //Create the msg object to be sent
            MailMessage msg = new MailMessage();
            //Add your email address to the recipients
            msg.To.Add(txt_email.Text);
            //Configure the address we are sending the mail from
            MailAddress address = new MailAddress("[email protected]");
            msg.From = address;
            //Append their name in the beginning of the subject
            msg.Subject = "Your KDH Parking Reciept";
            msg.Body = "Thank you for parking with us. You are parked in " + _spot + " and your permit expires at " + _timeExp.ToString(@"hh\:mm\:ss") + ".";

            //Configure an SmtpClient to send the mail.
            SmtpClient client = new SmtpClient("mail.stevebosworth.ca");
            client.EnableSsl = false; //only enable this if your provider requires it
            //Setup credentials to login to our sender email address ("UserName", "Password")
            NetworkCredential credentials = new NetworkCredential("[email protected]", "Pa55w0rd!");
            client.Credentials = credentials;

            //Send the msg
            client.Send(msg);
        }
        catch
        {
            //If the message failed at some point, let the user know

            lbl_message.Text = "Your message failed to send, please try again.";
        }
    }
开发者ID:stevebosworth,项目名称:Kirkland-District-Hospital,代码行数:45,代码来源:pp_public_sb.aspx.cs

示例9: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        emailid.Value = Request["email"].ToString();
            if (emailid.Value != "")
            {

                //check email first
                userMasterBO.email = emailid.Value;
                if (!IsPostBack)
                {
                bool valid = userMasterBAL.checkValidEmailToResetPassword(userMasterBO);

                if (valid == true)
                {

                    // first create the passcode here. to generate passcode  i have to write the storedprocedure

                    // now first check  passcode is null or not.

                    Random rnd = new Random();
                    int passcode = rnd.Next(00000000, 99999999);
                    userMasterBO.passcode = passcode;

                    //code to send email
                    MailMessage vMsg = new MailMessage();
                    MailAddress vFrom = new MailAddress("[email protected]", "RATEmymp");
                    vMsg.From = vFrom;
                    vMsg.To.Add(emailid.Value); //This is a string which contains delimited :semicolons for multiple
                    vMsg.Subject = "Passcode to reset Password in rateMyMp"; //This is the subject;
                    vMsg.Body = passcode.ToString(); //This is the message that needs to be passed.

                    //Create an object SMTPclient for relaying
                    // SmtpClient vSmtp = new SmtpClient();
                    SmtpClient vSmtp = new SmtpClient("smtp.gmail.com", 587);
                    vSmtp.Host = ConfigurationManager.AppSettings["SMTP"];
                    vSmtp.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["FROMEMAIL"], ConfigurationManager.AppSettings["FROMPWD"]);
                    //vSmtp.Credentials = new System.Net.NetworkCredential("lovelybatch", ConfigurationManager.AppSettings["FROMPWD"]);
                    vSmtp.EnableSsl = true;
                    vSmtp.Send(vMsg);

                    //now store same passcode in database under corresponding email address
                    bool success = userMasterBAL.insertPasscode(userMasterBO);
                    if (success == true)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "myfunction", "information()", true);
                    }
                }
                else
                {
                    Response.Redirect("Default.aspx");
                }
                }
            }
            else
            {
                //redirect to home page.
                Response.Redirect("Default.aspx");

            }
    }
开发者ID:rathoredev,项目名称:RateMyMp,代码行数:60,代码来源:forgetPassword.aspx.cs

示例10: Submit_Click

    protected void Submit_Click(object sender, EventArgs e)
    {
        MailAddress mailFrom = new MailAddress("[email protected]");
        MailAddress mailTo = new MailAddress("[email protected]");

        MailMessage emailMessage = new MailMessage(mailFrom, mailTo);

        emailMessage.Subject = "Unsubscribe";
        emailMessage.Body += "<br>Email: " + email.Text;

        emailMessage.IsBodyHtml = false;

        SmtpClient myMail = new SmtpClient();
        myMail.Host = "localhost";
        myMail.DeliveryMethod = SmtpDeliveryMethod.Network;

        //myMail.Port = 25;
        NetworkCredential SMTPUserInfo = new NetworkCredential("[email protected]", "!p3Learning", "pinnacle3learning.com");
        //myMail.UseDefaultCredentials = false;
        myMail.Credentials = SMTPUserInfo;

        myMail.Send(emailMessage);

        MultiView1.ActiveViewIndex = 1;
    }
开发者ID:KungfuCreatives,项目名称:P3WebApp,代码行数:25,代码来源:unsubscribe.aspx.cs

示例11: SendEmail

    public void SendEmail(string mailSubject, string mailBody, string users, string username, string password,string host,string emal)
    {
        try
        {

            MailAddress ma= new MailAddress(users,"ray");

            //Preparing the mailMessage
            MailMessage mail = new MailMessage();
            mail.Subject = mailSubject;
            mail.From = ma;
            mail.To.Add(emal);
            mail.Body = mailBody+"please login to score those articles";
            mail.IsBodyHtml = true;

            //Preparing the smtp client to send the mailMessage

            SmtpClient smtp = new SmtpClient(host);

            smtp.Credentials = new System.Net.NetworkCredential
                 (username, password);
            smtp.EnableSsl = true;
            smtp.Port = 587;

            //Sending message using smtp client
            smtp.Send(mail);
            cs.writelog(" auto email has send to  " + username+" on "+DateTime.Now.ToString());
            Label1.Text="Your Message has been sent successfully";
        }
        catch (Exception ex)
        {
            Label1.Text="Message Delivery Fails"+ex.Message;

        }
    }
开发者ID:rayli2011,项目名称:hopkins-upload,代码行数:35,代码来源:Faculty.aspx.cs

示例12: Envio

    public void Envio(Correo c)
    {
        MailMessage mensaje1 = new MailMessage();
            MailAddress dirCorreo = new MailAddress(c.Origen);

            SmtpClient cliente = new SmtpClient("smtp.1and1.es",25);
            NetworkCredential nc = new NetworkCredential(usuario, password);

            cliente.Credentials = nc;

            foreach (string x in c.Destinatarios)
            {
                mensaje1.To.Add(x);
            }

            if (copiaOculta != null)
            {
                mensaje1.Bcc.Add(copiaOculta);
            }

            mensaje1.IsBodyHtml = true;
            mensaje1.From = dirCorreo;
            mensaje1.Subject = c.Asunto;
            mensaje1.Body = c.Cuerpo;

            cliente.Send(mensaje1);
    }
开发者ID:ClickApp,项目名称:crackcompany,代码行数:27,代码来源:Correo.cs

示例13: SendMail

    public static string SendMail(string gooLogin, string gooPassword, string toList, string from, string ccList, string subject, string body)
    {
        MailMessage message = new MailMessage();
        SmtpClient smtpClient = new SmtpClient();
        string msg = string.Empty;
        try
        {
        MailAddress fromAddress = new MailAddress(from);
        message.From = fromAddress;
        message.To.Add(toList);

        if (ccList != null && ccList != string.Empty)
            message.CC.Add(ccList);

        message.Subject = subject;
        message.IsBodyHtml = true;
        message.Body = body;

        smtpClient.Host = "smtp.gmail.com";
        smtpClient.Port = 587;
        smtpClient.EnableSsl = true;
        smtpClient.UseDefaultCredentials = true;
        smtpClient.Credentials = new System.Net.NetworkCredential(gooLogin, gooPassword);

        smtpClient.Send(message);
        msg = "Vaša poruka je uspješno poslana! Hvala!";
        }
        catch (Exception ex)
        {
        msg = ex.Message;
        }
        return msg;
    }
开发者ID:Svjetlana,项目名称:ows_projekt_velebit,代码行数:33,代码来源:Util.cs

示例14: CreateMailAddress

        /// <summary>
        ///     创建邮箱账号
        /// </summary>
        /// <returns>邮箱账号</returns>
        public static MailAddress CreateMailAddress()
        {
            var mailAddress = new MailAddress();

            mailAddress.GenerateNewIdentity();
            return mailAddress;
        }
开发者ID:unicloud,项目名称:FRP,代码行数:11,代码来源:MailAddressFactory.cs

示例15: SendShippedOrderEmail

    /// <summary>
    /// Mail potwierdzający wysyłke zamówienia
    /// </summary>
    /// <param name="a_strMailAddress"></param>
    /// <param name="a_gActivationCode"></param>
    /// <param name="a_ctlOwner"></param>
    public static void SendShippedOrderEmail(string emailAddress, Order order)
    {
        MailDefinition mailDefinition = new MailDefinition();
        mailDefinition.BodyFileName = "~/MailTemplates/ZamowienieWyslane.html";
        mailDefinition.IsBodyHtml = true;
        mailDefinition.Subject = "Nazwa firmy - Zamówienie wysłano";
        IDictionary replacements = new Hashtable();

        //Dodawanie znaczników, które zostaną podmienione w szablonie maila na właściwe wartości
        replacements.Add("<%OrderDate%>", order.OrderDate.ToString("dd-MM-yyyy"));
        Address address = order.CustomerFacility.Address;
        String strAddress = "ul. " + address.Street +
            address.HouseNr + "/" + address.ApartmentNr + ", " +
            address.ZipCode + " " + address.City.Name + " " + address.Country.Name;
        replacements.Add("<%Address%>", strAddress);
        replacements.Add("<%Total%>", order.Total.ToString("0.00 zł"));

        MailMessage msg = mailDefinition.CreateMailMessage(emailAddress, replacements, new Panel());
        MailAddress mailFrom = new MailAddress(msg.From.Address, "Nazwa firmy");
        msg.From = mailFrom;

        SmtpClient client = new SmtpClient();
        client.EnableSsl = true;
        client.Send(msg);
    }
开发者ID:tsubik,项目名称:SFASystem,代码行数:31,代码来源:MailHelper.cs


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