简体   繁体   中英

Send email from C# WPF app without external SMTP

I need to find a way to send e-mails from my WPF application. Of course I tried sending it using for example Gmail SMTP and it works like a charm but for some reason this solution is unacceptable. So is there a way to send email straight from my computer without using any logging credentials or additional/not open source software? I tried something like this:

  SmtpClient m = new SmtpClient();
            m.Host = "xxx.xxx.xxx.xxx"; // my IP address.
            m.Port = 25;
            m.Send("Tests@xxx.xxx.xxx.xxx", "tests@gmail.com", "Test", "This is a test email.....");

It doesn't work like that, I've put mu IPV4 addres from ipconfig but the error I got is:

No connection could be made because the target machine actively refused it.

Is this even possible to run this straightforward from my PC like that? I assume its not even my static IP but some kind of dynamically changed IP from my ISP hidden behind NAT. How to configure it in other way?

My app is expected to run for example overnight and then I would like to receive and email after process is finished. Not interested in receiveing any other emails or sending emails to multiple users.

Sending email via SMTP is not complicated is just very legislated.

Each mail provider gmail/office365 has a configuration which you must follow exactly. The configuration is not even to send the email its just to autorize yourself for the smtp account being used.

Doing a quick search online for gmail the conditions are currently::

https://support.google.com/mail/answer/7126229?visit_id=1-636683482170517029-2536242402&hl=es&rd=1

Good luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM