on .NET Framework , allows applications to send e-mail by using the Simple Mail Transfer Protocol (SMTP)
Questions tagged [smtpclient]
1275 questions
13
votes
6 answers
How do I send an email from a Windows Phone 8 application?
In a Windows Forms project, I used the SmtpClient and MailMessage class in order to send information by email.
Is there an equivalent for Windows Phone 8?

user2087149
- 131
- 1
- 3
13
votes
2 answers
System.Net.Mail.SmtpException: The operation has timed out. error in asp.net send mail code using godaddy hosting
I am using following peace of code to send mail using godaddy hosting .
but its throw System.Net.Mail.SmtpException: The operation has timed out.
protected void sendmail()
{
var fromAddress = "frommailid@site.com";
// any…

rahularyansharma
- 11,156
- 18
- 79
- 135
12
votes
1 answer
SmtpClient.SendAsync Calls are Automatically Cancelled
Whenever I call smtpClient.SendAsync(...) from within my ASP.NET MVC application, the asynchronous requests are automatically cancelled, even though SendAsyncCancel() is never called.
Synchronous .Send(...) requests, on the other hand, go through…

Petrus Theron
- 27,855
- 36
- 153
- 287
12
votes
3 answers
Outlook SMTPClient server error 5.3.4 5.2.0
I have an MVC .NET web application that has been running stable for the most part of a year now. However today we received an error code and I'm having trouble finding how to resolve the issue.
In the application, I use SMTPClient to send emails…

Robin
- 2,704
- 7
- 30
- 47
12
votes
10 answers
SMTP 5.7.57 error when trying to send email via Office 365
I'm trying to set up some code to send email via Office 365's authenticated SMTP service:
var _mailServer = new SmtpClient();
_mailServer.UseDefaultCredentials = false;
_mailServer.Credentials = new NetworkCredential("test.user@mydomain.com",…

Rowland Shaw
- 37,700
- 14
- 97
- 166
12
votes
6 answers
Troubleshooting "Mailbox unavailable. The server response was: Access denied - Invalid HELO name" when sending email with SmtpClient
I have been trying to send an email by C#. I have Googled for various examples and have taken bits and pieces from each and from the standard code which everyone would most probably be using.
string to = "receiver@domain.com";
string from =…

user303907
- 543
- 2
- 9
- 18
12
votes
2 answers
Email sending service in c# doesn't recover after server timeout
I've been having this problem for months, and it's driving me nuts.
I have a windows service written in C# (.NET 4.5) which basically sends emails, using an outlook account (I think it's an office365 service). I'm aware of the "order of credentials"…

shinax
- 199
- 4
- 14
11
votes
1 answer
Changing name of automatic attached file in e-mail
I am using Mailkit library to send e-mails. This is the code to do so:
public async Task SendAsync(IdentityMessage message)
{
if (message == null)
return;
LinkedResource inline = new…

jstuardo
- 3,901
- 14
- 61
- 136
11
votes
2 answers
Dispose SmtpClient in SendComplete?
When I use SmtpClient's SendAsync to send email, how do I dispose the smtpclient instance correctly?
Let's say:
MailMessage mail = new System.Net.Mail.MailMessage()
{
Body = MailBody.ToString(),
IsBodyHtml = true,
From = new…

Jeff Chen
- 736
- 1
- 8
- 20
11
votes
8 answers
The remote name could not be resolved when sending mail using SMTP with Host as IP address
MailMessage message = new MailMessage();
message.Subject = "test";
message.Body = "test";
message.To.Add("test@gmail.com");
message.From = new MailAddress("bob@internalhost.com");
SmtpClient smtp = new SmtpClient();
smtp.DeliveryMethod =…

Lee Tickett
- 5,847
- 8
- 31
- 55
11
votes
1 answer
Cannot send emails to addresses with Scandinavian characters
Using SmtpClient, MailMessage and MailAddress classes, I cannot send to email addresses such as åbc.def@domain.se. I get the error/exceptions as shown below:
An invalid character was found in the mail header: 'å'.
---------------------------…

Mr. Boy
- 60,845
- 93
- 320
- 589
11
votes
4 answers
Using System.Net.Mail in ASP NET MVC 6 project
I have trouble creating a simple mock mail sender within an ASP NET 5 project.
Here the method :
public static Task SendMail(string Email, string Subject, string Body)
{
SmtpClient client = new SmtpClient();
…

Camille Laborde
- 858
- 11
- 17
10
votes
1 answer
Using SmtpClient to send an email from Gmail
I'm trying to connect to my Gmail account through SmtpClient but it seems to not work as should. I specify port 465, enable SSL and define everything, but it takes like 2 minutes and then just shows some error that the message wasn't sent.
What am I…

HelloWorld
- 1,128
- 1
- 7
- 14
10
votes
1 answer
SendMailAsync : An asynchronous module or handler completed while an asynchronous operation was still pending
While using SendMailAsync I am getting the following error:
An asynchronous module or handler completed while an asynchronous
operation was still pending
My code :
public static async Task SendEmail(MessageContent messageContent, string…

Bokambo
- 4,204
- 27
- 79
- 130
10
votes
1 answer
How can we log the SMTP conversation with SmtpClient?
E.g., for troubleshooting I need to see what SMTP messages go back and forth:
OUT : EHLO machinename
IN : 250-ReallyCoolEmailServer Hello [10.24.41.72]
IN : 250-SIZE
IN : 250-PIPELINING
IN : (...and so on...)
OUT : MAIL FROM:…

T.J. Crowder
- 1,031,962
- 187
- 1,923
- 1,875