Click here to Skip to main content
15,884,353 members
Everything / SmtpClient

SmtpClient

SmtpClient

Great Reads

by DataBytzAI
Easy way to send email on Azure with no mail server, using DNS MX and SMTP
by Afzaal Ahmad Zeeshan, Iqra Ali
Since I wrote an article previously, I had been asked on various occasions to share the code on Yahoo! or Bing, etc. I wanted to write an article, with the code, which covers all of those vendors as well.
by gfazzola
In this article I will explain the implementation of an infrastructure to host and manage windows services in a practical and interactive way.As a practical example of the solution will be implemented a dynamic ip update client of DucDNS
by Afzaal Ahmad Zeeshan
This article explains the core concepts about sending the emails over .NET framework and the problems that new .NET developers face in using them also some tips for removing very basic errors.

Latest Articles

by DataBytzAI
Easy way to send email on Azure with no mail server, using DNS MX and SMTP
by Afzaal Ahmad Zeeshan, Iqra Ali
Since I wrote an article previously, I had been asked on various occasions to share the code on Yahoo! or Bing, etc. I wanted to write an article, with the code, which covers all of those vendors as well.
by Richard Deeming
Adding cancellation support to the SendMailAsync method
by gfazzola
In this article I will explain the implementation of an infrastructure to host and manage windows services in a practical and interactive way.As a practical example of the solution will be implemented a dynamic ip update client of DucDNS

All Articles

Sort by Score

SmtpClient 

4 Feb 2018 by DataBytzAI
Easy way to send email on Azure with no mail server, using DNS MX and SMTP
8 Aug 2017 by Afzaal Ahmad Zeeshan, Iqra Ali
Since I wrote an article previously, I had been asked on various occasions to share the code on Yahoo! or Bing, etc. I wanted to write an article, with the code, which covers all of those vendors as well.
26 May 2016 by Dave Kreskowiak
The WHERE clause in your UPDATE statement should include the status as well:UPDATE EmailMaster SET status = 'I' WHERE mailid = 12345' AND status = 'P'If the update fails, your code will know that another service has checked out the record.But, seriously, I'd have some app running that is...
3 Nov 2014 by Richard Deeming
The only way to provide the user's GMail credentials would be to ask the user to enter them. Any user with an ounce of common sense wouldn't enter their GMail credentials on a random website, so I don't think that's going to work. :)You need to provide the credentials of your own GMail...
12 Oct 2015 by F-ES Sitecore
Set UseDefaultCredentials to false before you set the Credentials propertyhttps://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.usedefaultcredentials(v=vs.110).aspx[^]
10 Dec 2016 by gfazzola
In this article I will explain the implementation of an infrastructure to host and manage windows services in a practical and interactive way.As a practical example of the solution will be implemented a dynamic ip update client of DucDNS
26 Feb 2017 by Member 4653839
refer [^] string to = "jane@contoso.com"; string from = "ben@contoso.com"; MailMessage message = new MailMessage(from, to); message.Subject = "Using the new SMTP client."; message.Body = @"Using this new feature, you can send an e-mail message from an application very...
2 Aug 2020 by Garth J Lancaster
This line in your code Quote: using (SmtpClient smtp = new SmtpClient("darylds2001@gmail.com", 587)) is certainly wrong - the SmtpClient constructor takes the SMTP Host/Server ie email server ie "smtp.gmail.com" I know not from there this...
19 Jul 2014 by midnight_20
I am trying to send an email in asp.neti am accessing smpt ,username...atc parameters from web.config file.my all credentials are correct but each time i get this error.The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1...
18 Jul 2014 by Vedat Ozan Oner
set smtp.UseDefaultCredentials = false; when you are not using default credentials.see here: http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.usedefaultcredentials%28v=vs.110%29.aspx[^]
24 Jul 2014 by bholey
hi dear all,I have configured a virtual SMTP server inside server Using inetmgr6 and email sending code is like this :-public static Boolean SendEmailUsingGmail(some parameters) {SmtpClient smtp = new SmtpClient(); try {smtp.DeliveryMethod =...
24 Jul 2014 by hypermellow
Hi,The reason why smtp.send() is returning true is because of the way you have configured smtp delivery.You have set it up to use SmtpDeliveryMethod.PickupDirectoryFromIis.This setting will not directly use your local smtp service, but instead delivery email to the mailroot folder...
16 Nov 2014 by Ddev5a2
Hi,my code is not allowing me to pass Non-English characters to below function and contype is "text/calender" Attachment avCal = Attachment.CreateAttachmentFromString(str.ToString(), contype);is the any fix for this ?Thanks
17 Nov 2014 by Ddev5a2
by adding below i resolved Attachment avCal = Attachment.CreateAttachmentFromString(str.ToString(), filename+ ".ics");Thank you so much.
6 Jan 2015 by Member 8073143
hi tech guysi am facing a issue while sending mail through my C# codeThe error msg thrown after this this execution is smClient.Send(Msg);"Transaction failed. The server response was: 5.7.1 : Client host rejected: Access denied"can anybody help me ...
6 Jan 2015 by Praveen Kumar Upadhyay
It is something related to your firewall policy, which is not allowing you to send the mail outside the area.Please check below links where this problem is been answered.http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/MS-SharePoint/Q_28477111.html[^]...
13 Jan 2015 by Member239258
Hi frnds,Error during sending email from asp.net c#This is the error.A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 10.20.105.151:25yesterday it...
13 Jan 2015 by sashje-
Hi,And you have doublechecked that port 25 outbound is open? Easy to check if you are able to login to the server and doing a "telnet 10.20.105.151 25" from a console window..If not, you could always try to open a socket towards the port and adress using TcpClient.
23 Feb 2015 by Member 4663598
Hello,I'am developing a website "www.synergyprosale.com" using asp.net i'am facing a serious strange problem, which is the following:I'm using smtp email technique in sending email from the website, but the emails are not delivering to hotmail accounts, while they are receiving...
23 Feb 2015 by RajeeshMenoth
Hi,Try this..1) Send e-mail via SMTP using C#
3 May 2015 by Brady Kelly
I am trying to write a small tool to poll a POP3 account for new mails, then change a few addressing headers, then re-send via SMTP. I have some doubts and unknowns regarding how to best prepare the outgoing SMTP message.I have two third-party, candidate POP3 clients, given .NET's glaring...
7 Jun 2015 by Mehdi Gholam
Make sure the username and password is correct in the line:smtp.Credentials = new System.Net.NetworkCredential("computersaddict.himanshu@gmail.com", "password");try commenting the line :smtp.UseDefaultCredentials = false;Also try setting the properties outside the constructor:smtp.Host...
8 Jun 2015 by RajeeshMenoth
Hi,Check the solution 1 after follow this below steps.1) https://accounts.google.com/DisplayUnlockCaptcha[^] //Click allow access to your Google account2) You have to enable login from other timezone / ip for your google account.to do this follow the link...
21 Jul 2015 by user12213212
helloHow Do I Implement Error Handling when Sending Email with ASP.NET.Thank you in advance
21 Jul 2015 by Wendelius
Taken that you use C# you put the code sending the email inside a try..catch block. See How to: Use the Try/Catch Block to Catch Exceptions[^]
21 Jul 2015 by 1984.santosh
You can use try catch block to handle exception in email code block.try{//code to send email}catch (SmtpException ex){ //log exception or throw to upper layer as per your requirement}catch (Exception ex) //This will handle errors other than thrown feature other than...
29 Jul 2015 by bspilove
Put smtp.UseDefaultCredentials = false; above the smtp.Credentials assignment.
22 Sep 2015 by NekoNao
Dim clie As New SmtpClient("smtp.gmail.com", 587)clie.Credentials = New Net.NetworkCredential(txtemail.Text, txtpass.Text)Dim fromwho As String = "abcdef@noreply.com"Dim towho As String = txtto.TextDim subject As String = txtsubject.TextDim body As String =...
23 Sep 2015 by Sisir Patro
Hi,Try like this.Dim Smtp_Server As New SmtpClient Dim e_mail As New MailMessage() Smtp_Server.UseDefaultCredentials = False Smtp_Server.Credentials = New Net.NetworkCredential("username@gmail.com", "password") Smtp_Server.Port = 587 ...
12 Oct 2015 by kiran kumar
No answer found even after searching many sitesi am using VS2010(Frame work 4.0) and SQL 2012 , we are using exchange server....same mail configuration is working in java application but not working in c#button click code is : try { SmtpClient smtp = new...
30 Dec 2015 by SujataJK
Hi, Here i am facing problem during email send via rediffmail smtp client. Here email send properly using gmail and webmail(smtp.logix.in)Following is my code..... MailMessage Message = new MailMessage(); Message.IsBodyHtml = true; string...
6 Apr 2016 by Member 11525563
Hi does anyone know why the email that i sent in outlook using smtpclient is not displaying the image??the error on the image says "The linked image cannot be displayed"What I have tried:Outlook.Application app = new Outlook.Application(); Outlook.MailItem item =...
6 Apr 2016 by leon de boer
It has nothing to do with the sending the receiving email client has a setting that prevents it.For example outlook 2013 will block links, images and I think all HTML stuff by default in emails because users like me consider such stuff spam. If you want them displayed you have to go an...
26 May 2016 by maverick1991
I am using 3 windows services for sending bulk mail using SMTP in C#.I am selecting one row at a time using "select top 1 * from EmailMaster with (updlock) WHERE STATUS='P' ORDER BY MAILID"and then update the status to I when there is a record using Update EmailMaster set status='I'...
17 Jul 2016 by d_wade
Also, be sure you're using the actual office365 email address for the account. You can find it by clicking on the profile button in Outlook365. I wrestled with authentication until I realized the email address I was trying to use for authentication wasn't the actual mailbox email account. it...
23 Oct 2016 by Adam Welfburger
Hi y'all,I have an issue with a simple email client, the code works fine. However, the message is not delivered into Gmail/Hotmail inbox. I was wondering if I need to write the code into ASP.NET instead of WinForms project. Here's the code below, please advise.using System;using...
23 Oct 2016 by Mehdi Gholam
Read this : .net - Sending email through Gmail SMTP server with C# - Stack Overflow[^]
9 Jan 2017 by m.conta
In my case after I tried all this suggestion without luck, I contacted Microsoft support, and their suggestion was to simply change the password. This fixed my issue. Note that the password wasn't expired, because I logged on office365 with success, however the reset solved the issue.
6 Apr 2017 by Suvabrata Roy
Hi, First the SMTP server should be accessible from the hosted server. Type below command after opening CMD in administrator mode from hosted server Telnet [SMTP Server IP / Name] [Port] if its not accessible then as your infra guy to do the needful.
17 Apr 2017 by Dave Kreskowiak
That's not a "null server" error. That's a SEVERE error, meaning that the code cannot continue. There error message is telling you exactly what to do. You should try reading it again and reading up on the STARTTLS command.
23 Apr 2017 by Member 10549697
Quote: In this code I'm passing values from page A to page B using ajax code function myFunction(id) { var host = window.location.hostname; // Create our XMLHttpRequest object var hr = new XMLHttpRequest(); // Create some variables we need to...
19 Jun 2017 by Member 13266687
I have inherited a system with an exe that emails an attachment PDF via the .net SMTPClient. (I am just an administrator and not a code developer so forgive me for any errors) When the PDF gets a little Bigger it times out ... I gather I need to change the namespace System.Net.Mail and the...
19 Jun 2017 by ZurdoDev
The timeout property for SMTP is not available in web.config which means you have to change it in code. If you do not have the source code then you cannot change it. Perhaps you can look into making the pdf smaller some way.
6 Nov 2019 by KentJ05
Hi I am getting a time out when I try to send email with VB.net using ssl. It works fine if I disable SSl and use port 25. I have tried enabling SSL and using both port 465 and 587 and every time it times out when I try to send. We use this mail server to send out email with ssl on port 465...
17 Dec 2019 by MadMyche
Without the actual code it is hard to understand exactly how you are attempting to reply to an email. I would suggest that you read through the Answers to this S/O question: c# - Reply to a Mail in Mailkit - Stack Overflow[^]
2 Aug 2020 by OriginalGriff
At a guess, you didn't fill in the bits right: the ones where it says "enter whatever email you are sending from here" and "Enter email with password" Unless these match with the settings on your email server, the mail will not go out. Use the...
15 Mar 2021 by auto9817
I am implementing some multiple email sending application with Csharp. Basically I am just sending 100 emails in three different threads with indepent smtp parameters. Emails can be sent at the same time in the three different threads. This...
28 May 2021 by Matthew Dennis
Take a look at System.Threading.Channels or the older System.Threading.Tasks.Dataflow libraries. Both allow you to create fan out the number of tasks that pull from concurrent queues and act on it. We use it for a number of things, including...
8 Nov 2021 by Richard MacCutchan
You need to add the authentication details to the SMTP object. See SmtpClient.Credentials Property (System.Net.Mail) | Microsoft Docs[^]
1 Apr 2022 by Member 11677920
For 10 years I've used same code - very similar to that which follows. All of a sudden I'm getting an error: "Mailbox Unavailable 5.5.1 Authentication required". Using VB.net, my code: Imports System Imports System.IO Imports System.Net.Mail ...
12 Apr 2022 by Christopher Fernandes
I have a ASP.net Web Forms Application using .net framework v4.0 hosted on the intranet of my organisation Recently the app stopped sending emails here is the code public void SendMail(string host, string userid, string password, string...
12 Apr 2022 by Christopher Fernandes
Just changed the .Net Framework to v4.8 and it got fixed.
21 Sep 2023 by OriginalGriff
You need to consult with the author of the code, not a "random website" that has never seen the project before. If you look on the Github page, you will see an "Issues" option on the menu bar - use that to talk to the author and see if he can...
6 Mar 2024 by Odukoya Ademola
*Title*: Error: Failed to start TLS when sending OTP email using Mailtrap in Go *Description*: I'm working on implementing OTP email verification for user sign-in in my Go application using Mailtrap as the SMTP server. However, when attempting...
6 Mar 2015 by Afzaal Ahmad Zeeshan
This article explains the core concepts about sending the emails over .NET framework and the problems that new .NET developers face in using them also some tips for removing very basic errors.
2 Aug 2017 by Richard Deeming
Adding cancellation support to the SendMailAsync method
25 Nov 2015 by Member 11266633
I have code that send message to purpose email. When i run program from Windows - charset work correctly. But when i run this app in Linux VDS (Centos) charset incorrect - example ����������� ���. Message on cyrillic. I try make charset utf-8, but it also not workSmtpClient smtp = new...
12 Jun 2016 by Sumit Bhargav
I am sending an email, passing a string body(returning string via partial view), the string contains anchor or img tags. After receiving mails, i get to know that Anchor tags href attribute is not present , similarly img tag's src attribute is not present.How can i made them available?Here...
30 Jul 2014 by Vibusuna
Please help to get a solution to include voting buttons in email using SMTP host and not via Outlook functionality.
9 Feb 2022 by zhenbang bang
this is the code error : System.Net.Mail.SmtpException HResult=0x80131500 Message=Failure sending mail. Source=System StackTrace: at System.Net.Mail.SmtpClient.Send(MailMessage message) at Verification.Form1.button1_Click(Object...
8 Jun 2015 by Member 11749343
protected void Button1_Click(object sender, EventArgs e) { try { SmtpClient smtp= new SmtpClient("smtp.gmail.com", 587); smtp.EnableSsl = true; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.UseDefaultCredentials = false; ...
21 Sep 2023 by Member 13961671
B"H Code found here Client https://github.com/ymerkos/awtsfaria/blob/main/ayzarim/awtsmoosEmailClient.js[^] Server https://github.com/ymerkos/awtsfaria/blob/main/ayzarim/email.js[^] Problem: Client is not sending any emails no matter what....
3 Nov 2014 by Member 11176603
I am developing a web application which has a concept of sending email.Once the user gives the receiver's mail id and content,the mail will be sent from the user's mail id(Which would be unique for all the user's).This is my code if (Page.IsValid){ MailMessage mailmessage = new...
24 Dec 2020 by Member 11042100
I have to send mail using my web application. Given below code showing error. The error is : The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM. Help me to...
10 Jul 2015 by Member 11828636
Can anyone guide me, where to find servicestack server sent event sample code.First I explain my issue. I have created a restful service(using servicestack framework) to pull down list of emails for inbox folder using afterlogic mailbee object(external product). Now, each time if I do a...
20 Nov 2020 by Member 13004859
Hi all,I am newbie to ASP.NET and now start learning MVC , to enhance my skills on .NET platform . Currently , i am practicing myself to do different task & pretty much know about MVC and eager to know how we can send email to client mailbox by using MVC5 . Can anyone share any link or blog ;...
6 Apr 2017 by Member 10484162
i am tried to send an email using smtp in .net mvc with pdf attachment (in memory attachment), its working on local host but when we deplyed on IIS server geting the following exception. system.net.mail.smptp exception 'failure sending mail' What I have tried: ...
17 Apr 2017 by Anup KumarArya
//import static com.sun.org.apache.xalan.internal.lib.ExsltDatetime.date; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Date; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import javax.mail.*; import...
8 Oct 2018 by Jayanta Modak
showing Error "Failure sending mail." please help me i used port 587 because maximum example 587 used this port how i can know the my mail port or it is right error in this line SMTP.Send(Mail) massage is:- Just "Failure sending mail." What I have tried: Imports System.Net.Mail Public...
17 Dec 2019 by ahmed_sa
I doing contact system web application using c sharp asp.net using library mail kit the problem is when some one reply to my email from outlook 2010 to any email I sent it then on my web application reply id on debug show null when receiving . so How any email server like google,Microsoft know...
21 Mar 2021 by Member 14976405
Hello! Dev. i Am working on project and the project is is ASP.net c#, I want to send Email on signup to user and owner of that site that the demo user create his/her account, and the same thing i use on contact us page, but My email code is...
9 Jan 2023 by Member 15421351
I am getting below exception while sending mail in c# Error in processing. The server response was: 5.7.3 STARTTLS is required to send mail [MR2P264CA0029.FRAP264.PROD.OUTLOOK.COM] What I have tried: Code used to send mail updated as below:...
8 Nov 2021 by Member 15421351
I am getting below error while trying to send mail in c#. The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 Client not authenticated to send mail....