Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using system.web.mail;
MailMessage objEmail          = new MailMessage();
            objEmail.To       = txtTo.Text;
            objEmail.From     = txtFrom.Text;
            objEmail.Subject  = "Test Email";
            objEmail.Body     = bodyName.Text;
            objEmail.Priority = MailPriority.High;
    SmtpMail.Send(objEmail);


I wanna want to send my mail with remote server.
Posted
Updated 4-May-12 16:17pm
v5
Comments
Anil Honey 206 4-May-12 7:16am    
What Exactly u you want? U You want to send mail to multiple users at a time.
Shahin Khorshidnia 4-May-12 22:20pm    
Please do not use sms words or street talking. You (both) have good enough time to type "you" and "want to" instead of "u" and "wana"

You will get at least 217 different answer related to the Email in ASPX

Email Asp.Net[^]

Hope it helps :)
 
Share this answer
 
C#
protected void btnSend_Click(object sender, EventArgs e)
    {
        try
        {

         
            SmtpClient serverobj = new SmtpClient();
            serverobj.Credentials = new NetworkCredential("anilmeets4u@gmail.com", "archuanil");
            serverobj.Port = 587;
            serverobj.Host = "smtp.gmail.com";
            serverobj.EnableSsl = false;
            obj = new System.Net.Mail.MailMessage();
            obj.From = new MailAddress("anilmeets4u@gmail.com", "AgileLearning.com", System.Text.Encoding.UTF8);
            obj.To.Add(ASPxtxtToUser.Text);
            obj.CC.Add(txtCcUser.Text);
            obj.Priority = System.Net.Mail.MailPriority.High;
            obj.Subject = txtSubject.Text;
            string date = DateTime.Now.ToString();
            obj.Body = ASPxMemo1.Text;
            HttpFileCollection hfc = Request.Files;
            for (int z = 0; z < hfc.Count; z++)
            {
                HttpPostedFile hpf = hfc[z];
                if (hpf.ContentLength > 0)
                {
                    uploadfile.SaveAs(Server.MapPath("MailFiles") + "\\" + Path.GetFileName(hpf.FileName));
                    string FileName = Server.MapPath("MailFiles") + "\\" + Path.GetFileName(hpf.FileName);

                    obj.Attachments.Add(new Attachment(FileName));
                    obj.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;


                    serverobj.Send(obj);
                    Page.RegisterClientScriptBlock("pageClose", "<script>alert('Your Request Send Sucessfully');</script>");
                }
            }

           

        }


        catch (Exception ex)
        {
            ex.ToString();
        }


    }

You can send mail with attachement also
 
Share this answer
 
v2
Comments
_Tushar Patil 4-May-12 8:19am    
Use Tags For Code...,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900