Questions tagged [system.net.mail]

System.Net.Mail is a namespace of the .NET framework. It contains classes used to send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery.

System.Net.Mail is a namespace of the .NET framework. It contains classes used to send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery.

References

290 questions
4
votes
1 answer

Is there a way to catch exceptions using System.Net.Mail.SendAsync()

I have a couple of methods already to send an email message syncronously. If an email fails, I use this fairly standard code: static void CheckExceptionAndResend(SmtpFailedRecipientsException ex, SmtpClient client, MailMessage message) { …
dotnetnoob
  • 10,783
  • 20
  • 57
  • 103
4
votes
4 answers

HTML4.0 SSRS report is squashed in Outlook when sent with System.Net.Mail. Is it fixable?

I'm using the SSRS web service to generate HTML4.0 format reports and then I'm trying to send them with System.Net.Mail (I know SSRS has built in report scheduling, but we have a requirement to handle all scheduled processes in a central location).…
adhocgeek
  • 1,437
  • 1
  • 16
  • 30
4
votes
2 answers

Send spreadsheet as email attachment using SpreadsheetGear

A client has asked me to enhance one of their apps in order to send out an email containing an excel spreadsheet. They happened to have an old copy of SpreadsheetGear (2009) lying around, so I thought it might save time if I used it. As it happens…
PeteH
  • 2,394
  • 1
  • 20
  • 29
3
votes
1 answer

Random "Index was outside the bounds of the array" as an SmtpException

I'm getting an exception randomly with the Send method shown below. The exception I'm getting is: Exception information: Exception type: System.Net.Mail.SmtpException Exception message: Failure sending mail. Inner exception information…
Jason N. Gaylord
  • 7,910
  • 15
  • 56
  • 95
3
votes
5 answers

asp.net net.mail - route all emails to a different email address in debug mode

Is there anyway to have all emails go to a different address when System.Web.HttpContext.Current.IsDebuggingEnabled is true? Or do I need a new class which I use to send email everywhere?
Shawn
  • 19,465
  • 20
  • 98
  • 152
3
votes
2 answers

Porting System.Web.Mail functionality to System.Net.Mail

The following function works perfectly: protected void SendWebMailMessage(string DisplayName, string From, string ReplyTo, string To, string Subject, string Body, string Attachments) { System.Web.Mail.MailMessage msg = new…
Tom V
  • 125
  • 5
  • 11
3
votes
3 answers

Problem while sending mail by System.Net.Mail C#

This is my mail sending code. I was getting "There is Invalid character in Mail Header" error.When i changed my Computer Name some shortest name. The problem solved. But in my domain whole computer names like "04500-ab04545.xxxdomain.gov.tr" so I…
Ozlem Balli
  • 67
  • 1
  • 7
3
votes
0 answers

Send mail via smtp.office365.com using other email address as the FROM address

I want to sending email through smtp.office365.com in VB.NET It work!! when i use "FROM" address same as user authentication BUT how to send emails using other email address as the FROM address in domain I try "Mailbox Delegation" set other email…
almond
  • 31
  • 2
3
votes
2 answers

Clone or make a MailMessage Immutable in .NET / C#

I'm writing a small library where I'm writing some interfaces that takes a MailMessage object and returns a class back to me with a single send method that abstracts away how that MailMessage will be sent. I have control over the class that will do…
whaley
  • 16,075
  • 10
  • 57
  • 68
3
votes
2 answers

SmtpFailedRecipientsException Not working

I need to check if mail was send to existing recipient Here is my code try { var smtpServer = new SmtpClient("smtp.gmail.com", 587) { Credentials = new System.Net.NetworkCredential(MAIL_FROM,…
Stecya
  • 22,896
  • 10
  • 72
  • 102
3
votes
3 answers

Digitally Signing Email

I have an application which is sending out customer statements. I have a request to digitally sign the email (with pdf attachment) from a few customer. I am using System.Net.Mail currently to send email. I can't seem to find a clear answer, can this…
Saif Khan
  • 18,402
  • 29
  • 102
  • 147
3
votes
1 answer

system.net.mail isbodyhtml = true vs two AlternateViews pros/cons

Here is the use case: I am making an app that will email HTML Newsletters. The app will also email a plain text version of the newsletter as an alternate view. The way I see it there are two ways of going about this when using the system.net.mail…
Solracnapod
  • 843
  • 3
  • 13
  • 23
3
votes
1 answer

Sending rich text to email

I faced a problem sending the text as html markup in a message to mail. At first, I convert rtf to html string GetHtmlContent(string someRTFtext) { RichEditDocumentServer server = new RichEditDocumentServer(); server.RtfText = someRTFtext; …
Igor Klimenko
  • 29
  • 1
  • 6
3
votes
4 answers

What is the best method for formatting email when using System.Net.Mail

Hi I'm using System.Net.Mail to send some HTML formatted emails. What is the correct method for inserting css into the email message? I know I can apply formatting to each item, but I'ld rather use style sheets.. EDIT I should have mentioned that…
Ian G
  • 29,468
  • 21
  • 78
  • 92
3
votes
3 answers

How to use email adresses with special chars such as Ø

By writing this: var recipient = new MailAddress("name@abcø.dk"); Notice the "ø" in the domain part. I get an exception stating: System.FormatException: The specified string is not in the form required for an e-mail address. at…
Sir Code-A-Lot
  • 595
  • 6
  • 16