Is there any existing API tool, to be embedded on an ASP page, to receive/send mails on the designated domain, with Email service?
How about SendGrid introduced in the Microsoft document Account confirmation and password recovery in ASP.NET Core?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
Is there any existing API tool, to be embedded on an ASP page, to receive/send mails on the designated domain, with Email service?
Is there any existing API tool, to be embedded on an ASP page, to receive/send mails on the designated domain, with Email service?
How about SendGrid introduced in the Microsoft document Account confirmation and password recovery in ASP.NET Core?
Hi Peter_1985,
Thank you for posting in the Q&A Forums.
In ASP.NET or ASP.NET Core, sending and receiving emails typically involves using the SMTP, POP3, or IMAP protocols, along with the corresponding libraries or APIs. There are no API tools directly embedded on an ASP page to accomplish these tasks, but you can integrate these libraries and APIs to achieve the desired functionality.
Please note that security and privacy are very important when handling email. Ensure that your application follows best security practices and protects users' privacy and data.
Best regards
NeuviJ
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Does it mean we directly retrieve the mail details from the mail server, right?
The first step is checking with your email provider. You want find out of your provider has an API. Then learn how the API works by reads their docs. If the email provider does not have an API then you can look into POP3 and IMAP protocol for reading emails.
POP3 only allows downloading email messages from the server to the client. With IMAP, the emails messages are stored on the server and your code can interact with the server. To learn about IMAP or POP3 or find if anyone has written an IMAP or POP3 client in C# you can search GitHub or do a Google search.
Hi @Peter_1985,
Sorry, you didn't mention your .NET Framework version before, so I assumed you were using the latest version.
MailKit is not compatible with .NET Framework 4.5.
You can try the following method instead.
Sending emails in C# with SMTP
https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient?view=net-8.0
MailAddress to = new MailAddress("****");
MailAddress from = new MailAddress("***");
MailMessage message = new MailMessage(from, to)
{
Subject = "Good morning, Elizabeth",
Body = "Elizabeth, Long time no talk. Would you be up for lunch in Soho on Monday? I'm paying."
};
SmtpClient client = new SmtpClient("smtp.server.address", 2525)
{
Credentials = new NetworkCredential("smtp_username", "smtp_password"),
EnableSsl = true
};
// code in brackets above needed if authentication required
try
{
client.Send(message);
}
catch (SmtpException ex)
{
Console.WriteLine(ex.ToString());
}
Receiving emails is not a part of core C# stack so you will need to utilize some 3rd party libraries for that purpose. OpenPop.NET open-source library seems to be getting the job done in this case. You can use the following code to fetch the topics of incoming mail:
https://www.nuget.org/packages/OpenPop.NET/
var client = new Pop3Client();
client.Connect("pop.gmail.com", 995, true);
client.Authenticate("piotr@mailtrap.io", "My_password_here");
var count = client.GetMessageCount();
Message message = client.GetMessage(count);
Console.WriteLine(message.Headers.Subject);
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
I want to know the reason to the following. Currently, I am using smtp.domain1.org (not mail.domain1.org). Must I use mail.domain1.org?
-Q-
The server did not respond with a + response. The response was: "220 mail.domain1.org ESMTP"
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: OpenPop.Pop3.Exceptions.PopServerException: The server did not respond with a + response. The response was: "220 mail.domain1.org ESMTP"
Source Error:
Line 527: var client = new Pop3Client();
Line 528: client.Connect("smtp.domain1.org", 587, false);
Line 529: client.Authenticate("jane@domain1.org", "?");
-UQ-