Tag: smtp

当我的PC通过代理或无代理连接到互联网时,从Gmail,live,aol或yahoo帐户发送SMTP邮件

我想通过SMTP将C#中的电子邮件发送到不同的邮件提供商示例Gmail,Yahoo,AOL,Msn,Live等,以便我的代码可以正常工作,如果我的计算机通过代理连接到互联网或直接连接到互联网 。 (代理是一个转发代理,从内部网络接收请求并将它们转发到Internet,我在IE中配置代理) …………………………… 如果没有通过代理连接PC,我有代码可以发送SMTP邮件 public void SendMail(string senderId, string password, List To, List CC, List BCC, string Subject, string Body, List Attachment) { SmtpClient SmtpServer = null; string[] ss = senderId.Split(‘@’); string ServerName = ss[1].Substring(0, ss[1].IndexOf(“.”)); switch (ServerName.ToLower()) { case “gmail”: SmtpServer = new SmtpClient(“smtp.gmail.com”); SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential(senderId, password); SmtpServer.EnableSsl […]

SMTP中的传递通知

下面的代码工作正常。 但是我需要将失败或成功通知发送到特定地址(b@technospine.com)。 但是我收到了送货通知邮件到FromMail地址(A@technospine.com)。 你能帮我解决这个问题吗? SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); MailAddress fromAddress = new MailAddress(“A@technospine.com”, “BALA”); MailAddress adminAddress = new MailAddress(“b@technospine.com”); smtpClient.Host = “Mail Server Name”; smtpClient.Port = 25; smtpClient.UseDefaultCredentials = true; message.From = fromAddress; message.To.Add(_sendTo); //Recipent email message.Subject = _subject; message.Body = _details; message.IsBodyHtml = true; message.Headers.Add(“Disposition-Notification-To”, “b@technospine.com”); message.DeliveryNotificationOptions = […]

使用SendGrid发送包含附件的电子邮件

var myMessage = new SendGridMessage(); myMessage.From = new MailAddress(“info@email.com”); myMessage.AddTo(“Cristian “); myMessage.Subject = user.CompanyName + “has selected you!”; myMessage.Html = “Hello World!”; myMessage.Text = “Hello World plain text!”; // myMessage.AddAttachment(“C:\test\test.txt”); var apiKey = “”; var transportWeb = new Web(apiKey); transportWeb.DeliverAsync(myMessage); 基本上我可以使电子邮件工作,并且当我尝试添加附件时它不会发送它。 我尝试了不同的路径和不同的写路径方式,我不确定出了什么问题,我发现的每一个教程都表明它应该像这样工作。

SMTP发送正在锁定我的文件 – c#

我有一个function,发送消息(很多)和他们的附件。 它基本上循环遍历目录结构,并从文件结构创建电子邮件 c:\emails\message01 \attachments c:\emails\message02 \attachments 使用.net c#,标准内容创建消息。 创建完所有消息后……我有另一个直接运行的函数,它将消息文件夹复制到另一个位置。 问题是 – 文件被锁定了…… 注意:我没有移动文件,只是复制它们…. 有关如何使用c#复制锁定文件的任何建议? 更新 我有这个添加附件方法 private void AddAttachments(MailMessage mail) { string attachmentDirectoryPath = “c:\messages\message1”; DirectoryInfo attachmentDirectory = new DirectoryInfo(attachmentDirectoryPath); FileInfo[] attachments = attachmentDirectory.GetFiles(); foreach (FileInfo attachment in attachments) { mail.Attachments.Add(new Attachment(attachment.FullName)); } }

Gmail:如何以编程方式发送电子邮件

可能完全重复: 通过Gmail在C#.NET中发送电子邮件 嗨, 我正在尝试使用gmail发送电子邮件: 我尝试了在本网站和其他网站上找到的各种示例,但我总是得到同样的错误: 无法连接到远程服务器 – > System.net.Sockets.SocketException:无法建立连接,因为目标主动拒绝它209.85.147.109:587 public static void Attempt1() { var client = new SmtpClient(“smtp.gmail.com”, 587) { Credentials = new NetworkCredential(“MyEmailAddress@gmail.com”, “MyPassWord”), EnableSsl = true }; client.Send(“MyEmailAddress@gmail.com”, “some.email@some.com”, “test”, “testbody”); } 有任何想法吗? UPDATE 更多细节。 也许我应该说我做出的其他尝试给了我同样的错误:(注意当我没有指定端口时它尝试端口25) public static void Attempt2() { var fromAddress = new MailAddress(“MyEmailAddy@gmail.com”, “From Name”); var toAddress = new […]

System.Net.Mail.SmtpException:SMTP服务器需要安全连接或客户端未经过身份validation

我正在尝试从C#应用程序发送带有我网站地址的电子邮件。 直到最近,这种情况还好几个月。 (也许我的提供者改变了一些事情或其他人改变了设置) 这是代码: private void sendEmail(Email invite) { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient(smtpServerName); mail.From = new MailAddress(emailUsername); mail.To.Add(invite.RecipientEmail); mail.Subject = invite.MessageSubject; mail.Body = invite.MessageBody; SmtpServer.UseDefaultCredentials = false; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential(emailUsername, emailPassword); // SmtpServer.EnableSsl = true; SmtpServer.Send(mail); } 这是错误: SMTP服务器需要安全连接或客户端未经过身份validation。 服务器响应是:需要SMTP身份validation。 看看其他问题,我尝试了他们的建议,使SmtpServer.EnableSsl = true 。 这根本不起作用。 […]

如何在Asp.Net中发送带附件的电子邮件

我需要在asp.net中附上我的电子邮件图片,该文件已添加到解决方案资源管理器中,但我不知道如何添加此电子邮件,请指导我 我目前的代码如下 public void SendMail() { try { string receiverEmailId = “name@exmp.com”; string senderName = ConfigurationManager.AppSettings[“From”].ToString(); string mailServer = ConfigurationManager.AppSettings[“SMTPServer”].ToString(); ; string senderEmailId = ConfigurationManager.AppSettings[“SMTPUserName”].ToString(); string password = ConfigurationManager.AppSettings[“SMTPPasssword”].ToString(); var fromAddress = new MailAddress(senderEmailId, senderName); var toAddress = new MailAddress(receiverEmailId, “Alen”); string subject = “subject”; string body = “body.”; var smtp = new SmtpClient { […]

“在使用SMTP时,尝试以禁止其访问权限的方式访问套接字”

我试图在数据库中的某些值超过其阈值时发送邮件c#。 我已经在Windows防火墙中允许端口25,587和465。 并禁用防病毒软件中防止群发邮件的选项。 我正在使用的代码如下 using System.Net; using System.Net.Mail; using System.Net.Security; using System.Security.Cryptography.X509Certificates; MailMessage mailMsg = new MailMessage(); mailMsg.To.Add(“to@domain.com”); // From MailAddress mailAddress = new MailAddress(“from@domain.com”); mailMsg.From = mailAddress; // Subject and Body mailMsg.Subject = “MCAS Alert”; mailMsg.Body = “Parameter out of range”; SmtpClient smtpClient = new SmtpClient(“smtp.servername.com”, 25); smtpClient.UseDefaultCredentials = false; smtpClient.Timeout = 30000; System.Net.NetworkCredential […]

服务器响应是:5.7.57 SMTP; 客户端未通过身份validation,无法在MAIL FROM期间发送匿名邮件

我必须使用我的网络应用程序发送邮件。 鉴于以下代码显示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 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 […]

SMTP和OAuth 2

.NET是否支持通过OAuth协议进行SMTP身份validation? 基本上,我希望能够使用OAuth访问令牌发送有关用户行为的电子邮件。 但是,我在.NET框架中找不到对此的支持。 Google在其他环境中提供了一些示例 ,但不提供.NET。