通过C#中的桌面应用程序发送邮件 [英] sending mail through a desktop application in C#

查看:80
本文介绍了通过C#中的桌面应用程序发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想在我的桌面应用程序中编写一个用于发送邮件的代码,但我尝试了此代码,但它不起作用

Hi
I''d like to write a code for sending mail in my desktop application i tried this code but it is not working

using System.Net.Mail;

MailMessage mail = new MailMessage();
mail.From = new MailAddress("mymail@gmail.com");
mail.To.Add("mymail@hotmail.com");
mail.Subject = "my subj";
mail.Body = "first mail through desktop application";
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587); 
smtp.EnableSsl = true; 
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = new System.Net.NetworkCredential("mymail@gmail.com", "123456");
smtp.Timeout = 20000; 
smtp.Send(mail);



谢谢&关于



Thanks & Regards

推荐答案

无论如何,请查看以下内容:
类似的问题早于1 [ ^ ]
类似的问题已在早些时候回答了2 [
Whatever it is, have a look at these:
Similar question answered earlier-1[^]
Similar question answered earlier-2[^]


您看到我的文章了吗?
尝试该示例,它将起作用:

如何通过VB.NET或C#从GMAIL帐户发送邮件. Windows编程,具有一定的自定义功能 [ ^ ]
Did you see my article?
Try the sample and it will work :

How to Send Mails from your GMAIL Account through VB.NET or C#. Windows Programming, with a Bit of Customization[^]


这篇关于通过C#中的桌面应用程序发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆