smtpclient

Generate HTML e-mail with embedded images in Delphi

岁酱吖の 提交于 2019-11-27 07:04:15
问题 Anyone know of a good example of generating HTML e-mail with embedded images and an alternate text part? I need to generate some tabular reports in HTML and would like to embed logos and other images. I believe Indy can do this with some work, but I was hoping someone could point me to a good example as a starting point. I am open to using libraries other than Indy and commercial solutions provided source is available. Quality and time to implement is more important than cost. The solution

Sending mail through http proxy

纵然是瞬间 提交于 2019-11-27 06:07:46
问题 I'm trying to send emails from a system that connects to internet through a http proxy which is set in Internet Options. i'm using SmtpClient. Is there any way to send mails with SmtpClient through this proxy setting. Thanks 回答1: I understand that you want to use the browsers default settings, i would also like an answer for that. Meanwhile, you could do it manually. MailAddress from = new MailAddress("from@mailserver.com"); MailAddress to = new MailAddress("to@mailserver.com"); MailMessage

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

ε祈祈猫儿з 提交于 2019-11-27 03:34:55
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 this is a short test of the issue:" +" <a href='https://test.com/'>https://test.com/</a>: "; smtpClient

SMTP 5.7.57 error when trying to send email via Office 365

你说的曾经没有我的故事 提交于 2019-11-27 03:27:48
问题 I'm trying to set up some code to send email via Office 365's authenticated SMTP service: var _mailServer = new SmtpClient(); _mailServer.UseDefaultCredentials = false; _mailServer.Credentials = new NetworkCredential("test.user@mydomain.com", "password"); _mailServer.Host = "smtp.office365.com"; _mailServer.TargetName = "STARTTLS/smtp.office365.com"; // same behaviour if this lien is removed _mailServer.Port = 587; _mailServer.EnableSsl = true; var eml = new MailMessage(); eml.Sender = new

How to validate smtp credentials before sending mail?

牧云@^-^@ 提交于 2019-11-27 02:15:05
I need to validate the username and password set in an SmtpClient instance before sending mail. Using this code: SmtpClient client = new SmtpClient(host); client.Credentials = new NetworkCredential(username,password); client.UseDefaultCredentials = false; // Here I need to verify the credentials(i.e. username and password) client.Send(mail); How can I validate whether the user identified by the credentials is allowed to connect and send a mail? There is no way. SmtpClient bascially can not validate the usernamepassword without contacting the serve it connects to. What you could do is do it

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

放肆的年华 提交于 2019-11-27 01:35:28
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 this in a try/catch loop, but I'd rather do a test and then pop up a dialog saying: can't access smtp or

How to send email using simple SMTP commands via Gmail?

天涯浪子 提交于 2019-11-26 23:30:39
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 able to use TLS and authenticate to Gmail's SMTP server using command line (or sending commands myself in

System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated

南楼画角 提交于 2019-11-26 23:27:25
问题 I'm trying to send email with my website's address from a C# application. This worked fine for several months until recently. (maybe my provider changes some things or someone else changed settings) Here's the code: 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

android.os.NetworkOnMainThreadException sending an email from Android [duplicate]

心已入冬 提交于 2019-11-26 21:44:56
问题 This question already has an answer here: How do I fix 'android.os.NetworkOnMainThreadException'? 55 answers I have written an application which sends email from an Android device but I get the following exception when I try to send an email: android.os.NetworkOnMainThreadException Why is this occurring and how can I fix it? 回答1: Which SDK version? If 14+ see this link. the solution is JUST FOR DEBUG add these rows StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()

What are best practices for using SmtpClient, SendAsync and Dispose under .NET 4.0

浪尽此生 提交于 2019-11-26 21:25:48
I'm a bit perplexed on how to manage SmtpClient now that it is disposable, especially if I make calls using SendAsync. Presumably I should not call Dispose until SendAsync completes. But should I ever call it (e.g., using "using"). The scenario is a WCF service which mails out email periodically when calls are made. Most of the computation is fast, but the sending of email can take a second or so, so Async would be preferable. Should I create a new SmtpClient each time I send mail? Should I create one for the entire WCF? Help! Update In case it makes a difference, each email is always