smtpclient

Can send emails through Gmail account only if account has “Access for less secure apps” enabled

大城市里の小女人 提交于 2019-12-09 15:52:10
问题 If my Gmail account has Access for less secure apps disabled , then my application can't send emails through this account . Instead I get " The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required " exception. Here Google explains that by disabling Access for less secure apps , only apps that use modern security standards can sign in . What are those modern security standards my code needs to implement and can you

Difference between smtpClient.send() and smtpClient.SendAsync()?

天大地大妈咪最大 提交于 2019-12-09 08:35:33
问题 I am trying to send mail from localhost.. and on doing this i have got methods from different sites to sending mails..but on doing this i am confused between smtpClient.send() and smtpClient.SendAsync() .. I want to know that How they are different from each other??? Thanks in advance.. 回答1: smtpClient.send() will initiate the sending on the main/ui thread and would block. smtpClient.SendAsync() will pick a thread from the .NET Thread Pool and execute the method on that thread. So your main

Dispose SmtpClient in SendComplete?

两盒软妹~` 提交于 2019-12-09 03:01:19
问题 When I use SmtpClient's SendAsync to send email, how do I dispose the smtpclient instance correctly? Let's say: MailMessage mail = new System.Net.Mail.MailMessage() { Body = MailBody.ToString(), IsBodyHtml = true, From = new MailAddress(FromEmail, FromEmailTitle), Subject = MailSubject }; mail.To.Add(new MailAddress(i.Email, "")); SmtpClient sc = new SmtpClient(SmtpServerAddress); //Add SendAsyncCallback to SendCompleted sc.SendCompleted += new SendCompletedEventHandler(SendAsyncCallback); /

Adding Bcc to Email sending using .NET SmtpClient?

最后都变了- 提交于 2019-12-08 14:45:48
问题 When sending email using the SMTPClient class in ASP.NET C#, how can I add bcc to the email? How can I add bcc to a MailMessage instance? 回答1: MailAddress addressTo = new MailAddress("to@someone.com"); MailAddress addressFrom = new MailAddress("from@someone.com"); MailAddress addressBCC = new MailAddress("bcc@someone.com"); MailMessage MyMessage = new MailMessage(addressFrom, addressTo ); MyMessage.Bcc.Add(addressBCC); 回答2: You're looking for the aptly-named Bcc property: message.Bcc.Add("You

Get sent mail error

牧云@^-^@ 提交于 2019-12-08 14:04:48
问题 Is there any way to get sent error from the smtp to check if the mail is sent successfully? var smtpClient = new SmtpClient("SmtpServer"); smtpClient.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback); smtpClient.SendAsync(mail, userId); The errors I am looking for are: mail can't be deliver because the mail address not exists, mail box full etc... Regards, Meir. 回答1: I am not sure what you are trying to achieve but this will helps you. I assume you're already aware of the

5.7.0 Must issue a STARTTLS command first

时光毁灭记忆、已成空白 提交于 2019-12-08 11:20:54
问题 I'm trying to send email through C#. Although I beleive I've done everything right, it still throws this exception : "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at" At first I thought, it could be a zone/ip/region problem... But when i logged into gmail, there wasn't any warning of that. And to be sure, i've uploaded a file to a website to check from there, still the error was thrown.

How to set the attatchment file name with chinese characters in C# SmtpClient programming?

依然范特西╮ 提交于 2019-12-07 14:33:46
问题 my code is as below: ContentType ct = new ContentType(); ct.MediaType = MediaTypeNames.Application.Octet; ct.Name = "这是一个很长的中文文件名希望能用它在附件名中.Doc"; Attachment attach = new Attachment(stream, ct); but the attachement received is not with the right chinese filename, and I found the ct.Name becames "=?utf-8?B?6L+Z5piv5LiA5Liq5b6I6ZW/55qE5Lit5paH5paH5Lu25ZCN5biM5pyb?=\r\n =?utf-8?B?6IO955So5a6D5Zyo6ZmE5Lu25ZCN5Lit?=" in the VS2010 debuger. plz advice, how do I use the chinese charaters in

SmtpClient.Send randomly causes SmtpException 4.7.0 timeout waiting for client input

旧街凉风 提交于 2019-12-07 11:12:33
问题 I can't seem to find the cause for this problem. Sometimes I get SmtpException "4.7.0 timeout waiting for client input" being thrown on using the following c# code for .net-4.0: using System; using System.Net.Mail; namespace SendMail { class Program { static void Main(string[] args) { for (int i = 0; i < 100; i++) { string html = "<h1>TEST</h1>"; using (MailMessage mail = new MailMessage("sender@domain.com", "receiver@domain.com")) { mail.Subject = "Test"; mail.IsBodyHtml = true; mail.Body =

Troubleshooting “The server committed a protocol violation” when sending mail with SmtpClient

梦想的初衷 提交于 2019-12-07 02:21:38
问题 I want to send a mail message with the SmtpClient class. Here's the code I use: SmtpClient smtpClient = new SmtpClient("Host",25); NetworkCredential basicCredential = new NetworkCredential("UserName", "Password"); MailMessage message = new MailMessage(); MailAddress fromAddress = new MailAddress("me@domain.com"); smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = basicCredential; message.From = fromAddress; message.Subject = "test send"; message.IsBodyHtml = true; message.Body

“The function requested is not supported” exception when using SmtpClient in Azure role

狂风中的少年 提交于 2019-12-07 00:22:37
问题 I'm getting an exception when using SmtpClient in an Azure Web or Worker role. I created a console app to manually run on the role VMs via RDP to reproduce: using System; using System.Net; using System.Net.Mail; using System.Text; namespace ConsoleApplication1 { class Program { static void Main() { var mailClient = new SmtpClient("mail.redacted.com", 587); mailClient.EnableSsl = true; mailClient.DeliveryFormat = SmtpDeliveryFormat.International; mailClient.DeliveryMethod = SmtpDeliveryMethod