smtpclient

Can't auth to Gmail smtp via MailMessage & smtpClient

混江龙づ霸主 提交于 2019-11-26 13:58:29
问题 I cannot figure out for the life of my why this isn't working SmtpClient smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, UseDefaultCredentials = false, DeliveryMethod = SmtpDeliveryMethod.Network, Credentials = new NetworkCredential("myemail@gmail.com", "myGmailPasswordHere"), EnableSsl = true, Timeout = 10000 }; smtp.Send(mail); I get: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. I just

How to send an e-mail with C# through Gmail

时光总嘲笑我的痴心妄想 提交于 2019-11-26 13:19:10
问题 I am getting an error when trying to send an e-mail through my web service. I have tried enabling access to less secure apps disabling 2-step verification and logging into the account via a web browser. None of the solutions on SO have worked for me. I am still getting: Error: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. What can I do to fix this issue? namespace

System.Net.Mail creating invalid emails and eml files? Inserting extra dots in host names

会有一股神秘感。 提交于 2019-11-26 12:39:29
问题 It appears that .NET\'s SmtpClient is creating emails with an extra dot in host names if the dot was to appear at the beginning of a MIME encoded line (e.g. test.com sometimes shows up as test..com). Example code: [TestMethod] public void TestEmailIssue() { var mail = new System.Net.Mail.MailMessage(); var smtpClient = new System.Net.Mail.SmtpClient(); mail.To.Add(\"Test@test.com\"); mail.Subject = \"Test\"; mail.From = new System.Net.Mail.MailAddress(\"test@test.com\"); mail.Body = \"Hello

Can I test SmtpClient before calling client.Send()?

拜拜、爱过 提交于 2019-11-26 12:27:48
问题 This is related to a question I asked the other day on how to send email. My new, related question is this... what if the user of my application is behind a firewall or some other reason why the line client.Send(mail) won\'t work... After the lines: SmtpClient client = new SmtpClient(\"mysmtpserver.com\", myportID); client.Credentials = new System.Net.NetworkCredential(\"myusername.com\", \"mypassword\"); is there something I can do to test client before I try sending? I thought about putting

mail sending with network credential as true in windows form not working

微笑、不失礼 提交于 2019-11-26 08:52:47
问题 I want to do an application for sending emails in C# windows application.I used smtp server,but I don\'t want to set the network credentials. So I set it as true.but am getting error. 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 Here is the code: SmtpClient oClient = new SmtpClient(); oClient.Host = \"smtp.gmail.com\"; oClient.Port = 25; oClient.UseDefaultCredentials = true; oClient

How to send email using simple SMTP commands via Gmail?

☆樱花仙子☆ 提交于 2019-11-26 07:54:10
问题 For educational purposes, I need to send an email through an SMTP server, using SMTP\'s fundamental and simple rules. I was able to do that using smtp4dev. I telnet localhost 25 and and commands are: I want to do the same thing, using Gmail SMTP server. However, it requires authentication and TLS. I can\'t figure out how to do that for Gmail. Here\'s a screenshot of telnet smtp.gmail.com 587 : I searched and found many links including Wikipedia\'s article about STARTTLS command. But I\'m not

Send HTML email via C# with SmtpClient

▼魔方 西西 提交于 2019-11-26 06:37:52
问题 How do I send an HTML email? I use the code in this answer to send emails with SmtpClient , but they\'re always plain text, so the link in the example message below is not formatted as such. <p>Welcome to SiteName. To activate your account, visit this URL: <a href=\"http://SiteName.com/a?key=1234\">http://SiteName.com/a?key=1234</a>.</p> How do I enable HTML in the e-mail messages I send? 回答1: This is what I do: MailMessage mail = new MailMessage(from, to, subject, message); mail.IsBodyHtml =

C# sending mails with images inline using SmtpClient

北战南征 提交于 2019-11-26 04:38:50
问题 SmtpClient() allows you to add attachments to your mails, but what if you wanna make an image appear when the mail opens, instead of attaching it? As I remember, it can be done with about 4 lines of code, but I don\'t remember how and I can\'t find it on the MSDN site. EDIT: I\'m not using a website or anything, not even an IP address. The image(s) are located on a harddrive. When sent, they should be part of the mail. So, I guess I might wanna use an tag... but I\'m not too sure, since my

Why do I get “&#39;property cannot be assigned” when sending an SMTP email?

不羁的心 提交于 2019-11-25 22:44:47
问题 I can\'t understand why this code is not working. I get an error saying property can not be assigned MailMessage mail = new MailMessage(); SmtpClient client = new SmtpClient(); client.Port = 25; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Host = \"smtp.gmail.com\"; mail.To = \"user@hotmail.com\"; // <-- this one mail.From = \"you@yourcompany.com\"; mail.Subject = \"this is a test email.\"; mail.Body = \"this is my test email body\"; client