Questions tagged [mailmessage]

The MailMessage class can be considered the foundation class of the System.Net.Mail namespace.

The MailMessage class can be considered the foundation class of the System.Net.Mail namespace.

Instances of the MailMessage class are used to construct e-mail messages that are transmitted to an SMTP server for delivery using the SmtpClient class.

The sender, recipient, subject, and body of an e-mail message may be specified as parameters when a MailMessage is used to initialize a MailMessage object. These parameters may also be set or accessed using properties on the MailMessage object.

The MailMessage class also allows an application to access the headers collection for the message using the Headers property. While this collection is read-only (a new collection can not be set), custom headers can be added to or deleted from this collection.

324 questions
90
votes
4 answers

Send Email to multiple Recipients with MailMessage?

I have multiple email recipients stored in SQL Server. When I click send in the webpage it should send email to all recipients. I have separated emails using ;. Following is the single recipient code. MailMessage Msg = new MailMessage(); MailAddress…
Chetan Goenka
  • 969
  • 1
  • 7
  • 16
90
votes
5 answers

How to save MailMessage object to disk as *.eml or *.msg file

How do I save MailMessage object to the disk? The MailMessage object does not expose any Save() methods. I dont have a problem if it saves in any format, *.eml or *.msg. Any idea how to do this?
ashwnacharya
  • 13,821
  • 22
  • 82
  • 111
68
votes
4 answers

Resolving 'The specified string is not in the form required for a subject.'

I have a class that sends an Email (MailMessage) but I get the following error: "The specified string is not in the form required for a subject." Is there a handy dandy method to sanitize the strings or do I have to write my own?
Matt
  • 24,106
  • 61
  • 180
  • 291
28
votes
7 answers

Multiple address in MailAddress constructor

i was trying to add multiple to address like this. MailAddress mailAddressTo = new MailAddress("sample@google.com;sample1@google.com","Vetrivelmp"); but throws error like An invalid character was found in the mail header: ';'
Vetrivel mp
  • 1,122
  • 1
  • 12
  • 25
22
votes
5 answers

MailMessage c# - How to make it HTML and add images etc?

string to = "email@hotmail.co.uk"; string body = "Test"; SmtpClient SMTPServer = new SmtpClient("127.0.0.1"); MailMessage mailObj = new MailMessage(urEmail, to, subject, body); SMTPServer.Send(mailObj); This is how i am currently sending a test…
Beginner
  • 25,463
  • 62
  • 148
  • 228
14
votes
5 answers

Why does the MailDefinition class require a System.Web.UI.Control?

When creating a MailMessage object by calling the "CreateMailMessage" method on the MailDefinition class, the third parameter is an object of type System.Web.UI.Control. MailDefinition mail = new MailDefinition(); ListDictionary replacements = new…
John Bubriski
  • 18,881
  • 34
  • 115
  • 167
14
votes
4 answers

Getting a sent MailMessage into the "Sent Folder"

I'm sending MailMessages with an SmtpClient (being delivered successfully) using an Exchange Server but would like my sent emails to go to the Sent Folder of the email address I'm sending them from (not happening). using (var mailMessage = new…
Robert Reid
  • 395
  • 1
  • 5
  • 12
14
votes
1 answer

Set "From" address when using System.Net.Mail.MailMessage?

I'm trying to send a password reset email, but I'm having trouble figuring out how to specify the sender's address. Here's what I'm trying to do: MailMessage mail = new MailMessage(); mail.From.Address =…
Kehlan Krumme
  • 7,101
  • 12
  • 51
  • 96
13
votes
8 answers

Line breaks ignored when sending mail as plain text

I have a text like " Hi, \r\n this is test \r\n Thanks" I am sending the mail using MailMessage class. I have set the "IsBodyHtml" property to false. The issue is that I am receiving mails without line breaks. Can you let me know what I am missing?
Rocky Singh
  • 13,980
  • 28
  • 91
  • 142
13
votes
6 answers

How do I send an email from a Windows Phone 8 application?

In a Windows Forms project, I used the SmtpClient and MailMessage class in order to send information by email. Is there an equivalent for Windows Phone 8?
user2087149
  • 131
  • 1
  • 3
11
votes
1 answer

Attachments in Papercut

I am currently using Papercut in order to test sending emails over an SMTP server connection in C#. The emails that I need to send have files attached to them however the files do not seem to appear when I view the email on Papercut. I am sure the…
user3148942
  • 115
  • 7
11
votes
10 answers

MailMessage sent string as body without newline in outlook

HI, I am trying to send a simple notification using system.net.mail.mailmessage. I just pass the string as the message body. But problem is even though multi-line message been send have the correct "\r\n" format info in string. The mail opened in…
Paul L
  • 2,150
  • 3
  • 35
  • 54
11
votes
1 answer

Cancel outlook meeting requests via MailMessage in C#

I'm creating an application using the ASP.NET MVC 1 framework in C#, where I have users that register for events. Upon registering, I create an outlook meeting request public string BuildMeetingRequest(DateTime start, DateTime end, string attendees,…
BTmuney
  • 125
  • 1
  • 5
11
votes
6 answers

save System.Net.mail.MailMessage as .msg file

I am building an application where i am obligated to create a MailMessage (System.Net.mail.MailMessage) and save it on the disk as .msg extention not .eml Below is the method i'm using to save a MailMessage as .msg file: public static void…
Gaby
  • 2,893
  • 4
  • 33
  • 51
10
votes
2 answers

How to get the "Date" of an email?

I create an application that gets email from mail server. I use "System.Net.Mail.MailMessage" for receive email. Now I want to get "Date and Time" of each email that ins in Inbox.
Tavousi
  • 12,568
  • 15
  • 47
  • 65
1
2 3
21 22