mailmessage

How do I send an email message from my C# application?

This is the code I wrote: MailMessage mail = new MailMessage("[email protected]", "[email protected]"); mail.Subject = "This is a test!!"; mail.Body = "testing..."; SmtpPermission connectAccess = new SmtpPermission(SmtpAccess.Connect); System.Console.WriteLine("Access? " + connectAccess.Access); ...

Can I pass a System.Net.MailMessage to a WCF service?

I'd like to setup a WCF service to send emails. The System.Net.MailMessage doesn't seem to be serializable, and cannot be passed in a [DataContract] The error I receive is Type 'System.Net.Mail.MailAddress' cannot be serialized. Consider marking it with the DataContractAttribute Any suggestions? ...

Serialize a FileStream for transport

See also this question: http://stackoverflow.com/questions/447071/can-i-pass-a-system-net-mailmessage-to-a-wcf-service I'd like to add attachments to the mail being sent. Attachments are either files on the local disc, or dynamically created Streams. A WCF contract can contain a Stream, but only when all arguments are of type Stream. So...

Sending an email with the header return-path using windows virtual mail server

I'm trying to send an email message using the .NET MailMessage class which can also have the return-path header added so that any bounces come back to a different email address. Code is below: MailMessage mm = new MailMessage(new MailAddress(string.Format("{0}<{1}>", email.FromName, email.FromEmail)), new MailAddress(emailTo...

.NET MailMessage and SMTPClient Getting Tagged as Spam?

I'm preparing basic HTML email and have used a basic HTML template with proper HEAD and BODY tags, but for some reason, my users are having trouble getting emails from me. I'm using ASP.NET MailMessage and SMTPClient objects and the mail sends just fine, I can get test messages to myself and most users are getting them, but some sites a...

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 ListDictionary(); replacements.Add("<%myname%>", "John"); mail.BodyFileName = "~/App_Dat...

Convert MIME tree to MailMessage

I'm writing a a C# program that processes and forwards email messages. I have a POP3 library and a MIME parser, and I need to copy the MIME tree into a System.Net.Mail.MailMessage. What is the best way to map different MIME parts to AlternateViews, LinkedResources, and Attachments? EDIT: That will work with all mail clients (both send...

Properly disposing resources used by SmtpClient

I have a C# service that runs continuously with user credentials (i.e not as localsystem - I can't change this though I want to). For the most part the service seems to run ok, but ever so often it bombs out and restarts for no apparent reason (servicer manager is set to restart service on crash). I am doing substantial event logging, a...

ASP.net 3.5 Website Using ASP:Wizard Control and SMTPClient does not send Email

Hello, I have a asp:Wizard control on a site running Framework 3.5. I acquired the settings from the web host and have entered them into the Web Configuration Utility. Here's the code behind file: Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wi...

Embedding background images in an e-mail

Hi, I'm trying to use an embedded image in an e-mail as the background image, i've got the following code to embed it: LinkedResource backgroundLink = new LinkedResource("..\\..\\background.gif"); backgroundLink.ContentId = "BackgroundImage"; backgroundLink.TransferEncoding = System.Net.Mime.TransferEncoding.Bas...

Replace System.Net.Mail.MailMessage with manually created message and send it

I am trying to send emails that will bounce to a known mailbox. I plan to use VERP. Unfortunately the System.Net.Mail.MailMessage object does not allow me to precisely set the From: and Sender: headers within my email - it forces the values so that the resulting email contains the phrase 'on behalf of', and does not allow me fine contr...

Sending the same System.Net.MaiL.MailMessage to multiple recipients

I've got a method that basically has a "SendEmail" method (it will later be used by WCF service) It has params like, Subject, Body, etc... and a string[] of Recipients. What I do, is create a MailMessage based on the parameters, then send it using smtp - I know the MailMessage has a To MailAddressCollection, but if I add each address t...

changed MailMessage properties, now it's hanging on client.Send

Hi, I'm using System.Net.Mail.MailMessage to send emails from my C# Windows app. I originally had this: MailMessage mail = new MailMessage("[email protected]", "[email protected]"); etc which worked fine - but then I needed to add mulitple To addresses, so I changed it to this: MailMessage mail = new MailMessage(); mail.From = new Mai...

Format of EML files used by System.Net.Mail.MailMessage and Microsoft SMTP Server

I'm trying to wrap my head around the EML files I see generated by System.Net.Mail.MailMessage and generated or consumed by Microsoft's SMTP Server. I've been reading RFCs 5322 and 5321 and I'm trying to make sense of the format. Granted, the majority of the EML files I see are adherent to the message format described in 5322 (or 2322 ...

Send mail using RTF text as Body

Hi, I'm trying to create a mail message using some RTF text as the mail.body, but there's no IsRtfBody property on System.Net.Mail.MailMessage only IsHtmlBody. The test-mails I've received all contain {\rtf1\deff0{\fonttbl{\f0 Times New Roman;}{\f1 Verdana;}}{\colortbl\red0\green0\blue0 ;\red0\green0\blue255 ;}{\*\listoverridetable}{\...

How to pull content of an e-mail page/template into a MailMessage Body in .NET

I have an e-mail template which is just a plain, static HTML page. I need to get that page into the Body of a MailMessage. Normally what I would do is just create a StringBuilder and append the lines over and over. But it's kind of a long page, and I don't want to go through replacing the quotes with single quotes etc.. So is there a...

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

Hi, 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 Save(MailMessage Message, string FileName) { Assembly assembly = typeof(SmtpC...

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 MailMessage("[email protected]", "[email protected]", "subject", "body")) { var smtpCl...

Encoding Special Characters For Outlook HTML Email

I have an asp.net / C# page which takes a comment, and then emails that comment. Sometimes when the user enters "&" in the comment, the comment is being truncated. So for example if the comment is "test & test" the email only sends out "test ". I have tried HttpUtility.HtmlEncode - but it looks like the issue is on the outlook side and ...

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, string organizer, string subject, string description, string UID, string location) {...