KaranGupta
asked on
Problem in sending the email
Hi
I am using the following code to send an email
But I am getting runtime error
Can you please tell me the reason
I am using the following code to send an email
But I am getting runtime error
Can you please tell me the reason
MailMessage message = new MailMessage();
message.From = new MailAddress("sender@domain.com");
message.To.Add(new MailAddress(MailTo));
message.Subject = Subject;
message.Body = Body.ToString();
SmtpClient client = new SmtpClient("localhost");
client.EnableSsl = true;
client.Send(message);
ASKER
Hi
I have changed it to valid email id
But I am getting the same error
"Failure sending mail. "
I have changed it to valid email id
But I am getting the same error
"Failure sending mail. "
Is the machine you are running the code on (localhost) an SMTP server?
ASKER
No
I think we are using the the SMTP service in services.msc to send an email
I think we are using the the SMTP service in services.msc to send an email
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have an outlook configured on my machine
so I think my machine also configures for SMTP
so I think my machine also configures for SMTP
Does your Outlook go to localhost as well? If not, the copy the server address that Outlook is using into your
SmtpClient client = new SmtpClient("server_name_he re");
line.
SmtpClient client = new SmtpClient("server_name_he
line.
ASKER
Hi
SmtpClient client = new SmtpClient()
with this I want to use gmails smtp server
How can I specify here
SmtpClient client = new SmtpClient()
with this I want to use gmails smtp server
How can I specify here
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
message.From = new MailAddress("sender@domain
What error you are getting ?