1

I'm new to ASP.NET with C#. Can anybody guide me on how to send an email through ASP.NET with C# using server (including configuring the server).

1 Answer 1

4
using System.Net.Mail;
...

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

message.To.Add(new MailAddress("[email protected]"));
message.To.Add(new MailAddress("[email protected]"));
message.To.Add(new MailAddress("[email protected]"));

message.CC.Add(new MailAddress("[email protected]"));
message.Subject = "This is my subject";
message.Body = "This is the content";

SmtpClient client = new SmtpClient();
client.Send(message);

in the web.config

 <system.net>
<mailSettings>
  <smtp from="[email protected]">
    <network host="smtpserver1" port="25" userName="username" password="secret" defaultCredentials="true" />
  </smtp>
</mailSettings>

Thanks Scott

Sign up to request clarification or add additional context in comments.

3 Comments

hai thanx for your reply... can you please explain what is host-"smtpserver1" username="username" password="secret".... where i going to get all these...????
Google it, your can set up your own, use ur ISP's, use google/yahoo mails smtp servers.
hai paul thanx the mail send successfully but i use localhost for sending the mail. could you tell me where the mail is store in my mail???????

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.