system.net.mail

Error: Server does not support secure connections

老子叫甜甜 提交于 2020-01-01 20:38:10
问题 Ok, I have been using the following script for over a year now to send email (via gmail) from my host, and it has worked just fine (the Settings.Get() just return strings): public class Email : SmtpClient { public MailMessage Message { get; private set; } public Email(string to, string from, string subject, string body) : base(Settings.Get("smtp"), 25) { this.EnableSsl = Convert.ToBoolean(Settings.Get("ssl")); if(this.EnableSsl) this.Credentials = new System.Net.NetworkCredential(Settings.Get

Using a Html file for mail.body in .net.mail

廉价感情. 提交于 2019-12-25 02:07:38
问题 MVC3, VB.NET. I have a function in my app that is supposed to use a html file's contents for the email body. However what I have so far is failing at the mail.body = file.readalltext(_body) line.. Any ideas?? <Authorize(Roles:="Admin")> Function Notification(ByVal _email As String) As ActionResult Dim _body = Path.Combine((AppDomain.CurrentDomain.BaseDirectory) + "HtmlEmails\") + "HolidayEmail.htm" Dim SmtpServer As New SmtpClient() Dim mail As New MailMessage() mail.To.Add(_email) mail.From

Send mail in asp.net

不问归期 提交于 2019-12-23 17:00:13
问题 I am using asp.net 3.5 and C#. I want to send mail from asp.net, for that I have got some details from my hosting provider which are these: mail.MySite.net UserName Password But I am unable to send mail through these details, I have done the following changes in my web.config file: <system.net> <mailSettings> <smtp> <network host="mail.MySite.net" port="8080" userName="UserName" password="Password" /> </smtp> </mailSettings> </system.net> Also, at the code behind I am writing this function:

When does the empty MailMessage constructor work?

梦想与她 提交于 2019-12-22 09:39:36
问题 We have an Asp.Net solution that's been in production for over 2 years using System.Net.Mail.MailMessage with the empty constructor: using (MailMessage _mailMessage = new MailMessage()) // Exception thrown here { _mailMessage.From = new MailAddress(sFrom); // Setting additional properties - never gets here _mailMessage.Body = sBody; _mailMessage.Subject = sSubject; _mailMessage.IsBodyHtml = true; Yesterday we had a live site report the exception: The specified string is not in the required

GMail not showing inline-images (cid) i'm sending with System.Net.Mail

老子叫甜甜 提交于 2019-12-22 06:53:07
问题 When I send an email via outlook or gmail to a gmail email address I can add inline-images which are directly shown in the gmail webinterface: Relevant raw mail-header and raw body parts of the working email: --089e0158b6909948880520cef593 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Image there?<div><img src=3D"cid:ii_if3zqhar0_15014363be0a= 41b2" width=3D"10" height=3D"3"><br>=E2=80=8BHope so!<br></div></div> -

“Unable to read data from the transport connection: net_io_connectionclosed.” - Windows Vista Business and SMTP

此生再无相见时 提交于 2019-12-20 16:10:51
问题 Unable to test sending email from .NET code in Windows Vista Business. I am writing code which I will migrate to an SSIS Package once it its proven. The code is to send an error message via email to a list of recipients. The code is below, however I am getting an exception when I execute the code. I created a simple class to do the mailing... the design could be better, I am testing functionality before implementing more robust functionality, methods, etc. namespace LabDemos { class Program {

email attachment from the MemoryStream comes empty

拟墨画扇 提交于 2019-12-18 19:05:00
问题 _data is a byte[] array of Attachment data. When I'm doing this: var ms = new MemoryStream(_data.Length); ms.Write(_data,0,_data.Length); mailMessage.Attachments.Add(new Attachment(ms, attachment.Name)); Attachment comes empty. Actually outlook shows the filesize but it's incorrect. Well, I thought there is a problem in my _data. Then I decided to try this approach: var ms = new MemoryStream(_data.Length); ms.Write(_data,0,_data.Length); fs = new FileStream(@"c:\Temp\"+attachment.Name

.Net System.Mail.Message adding multiple “To” addresses

↘锁芯ラ 提交于 2019-12-18 12:45:14
问题 EDIT: This question is pointless, except as an exercise in red herrings. The issue turned out to be a combination of my idiocy (NO ONE was being emailed as the host was not being specified and was incorrect in web.config) and the users telling me that they sometimes got the emails and sometimes didn't, when in reality they were NEVER getting the emails. So, instead of taking proper steps to reproduce the problem in a controlled setting, I relied on user information and the "it works on my

Send SMTP email using System.Net.Mail via Exchange Online (Office 365)

冷暖自知 提交于 2019-12-17 10:23:43
问题 We are testing the new Office 365 beta, and i have a mail account on the Exchange Online service. Now I'm trying to connect a LOB application that can send smtp emails from my test account. However the Exchange 365 platform requires TLS encryption on port 587, and there is a 'feature' of System.Net.Mail that does not permit Implicit SSL encryption. Has anyone managed to get C# sending mails via this platform? I have the following basic code that should send the mail - any advice would be

Why do I get 5.5.4 Invalid Address error?

浪子不回头ぞ 提交于 2019-12-13 17:27:28
问题 I tried to send an email using the following code: MailMessage message = new MailMessage(); message.From = new MailAddress(fromMailAddress.Trim()); message.To.Add(new MailAddress(toMailAddress.Trim())); message.Subject = subject; message.Body = body; message.SubjectEncoding = System.Text.Encoding.UTF8; message.BodyEncoding = System.Text.Encoding.UTF8; SmtpClient client = new SmtpClient(); try { client.Send(message); } catch(Exception e) { throw e; } However, I got the exception: The server