I’m using MVC3 and need to send an email to a user. I don’t want to use a gmail server. But, I do want to use server 10.1.70.100. I don’t understand what I am doing wrong. Here is my code:
var fromAddress = new MailAddress("sum1@abc.com", "From Name"); var toAddress = new MailAddress(EmailID, "To Name");
const string fromPassword = "";//To be Filled
const string subject = "Verification Mail";
string body = "You have successfully registered yourself. Please Enter your Verification code " + code.ActivatedCode;
var smtp = new SmtpClient
{
Host = "10.1.70.100",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential(),
Timeout = 100000
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}
Can someone suggest a way through which I don’t have to give my credentials??
For our OSS project we use this little helper. Hope it helps.