mailmessage

Cancel outlook meeting requests via MailMessage in C#

♀尐吖头ヾ 提交于 2019-12-18 03:26:06
问题 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) { System.Text.StringBuilder sw = new System.Text.StringBuilder(); sw.AppendLine("BEGIN:VCALENDAR"); sw.AppendLine("VERSION:2.0"); sw.AppendLine("METHOD:REQUEST");

How to send Email to multiple Recipients with MailMessage?

感情迁移 提交于 2019-12-17 10:33:25
问题 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 fromMail = new MailAddress(fromEmail); Msg.From = fromMail; Msg.To.Add(new MailAddress(toEmail)); if (ccEmail != "" && bccEmail != "") { Msg.CC.Add(new MailAddress(ccEmail)); Msg.Bcc.Add(new MailAddress(bccEmail)); } SmtpClient a = new SmtpClient

Embedding background images in an e-mail

大憨熊 提交于 2019-12-13 12:06:45
问题 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.Base64; htmlView.LinkedResources.Add(backgroundLink); m.AlternateViews.Add(htmlView); Then in the e-mail body i've got the following code to test: <table background='cid:BackgroundImage'> <tr

Common algorithm issue while trying to send an email using C#

僤鯓⒐⒋嵵緔 提交于 2019-12-11 10:38:41
问题 I'm trying to send an email via my C# application, but every time i try to send the email, an error occurs, saying " A call to sspi failed ", when i look at the inner exeption it says something like " The client and server cannot communicate, because they do not possess a common algorithm " My code is this: try { var fromAddress = new MailAddress("sender@domain.com", "Sender"); var toAddress = new MailAddress("receiver@domain.com", "Receiver"); const string fromPassword = "Pass123"; const

C# Compress and zip csv from stream

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 02:29:48
问题 I have a MemoryStream which pulls data from a DataTable. Currently this feeds into a MailMessage Attachment and mails out a csv attached to the mail. What I need to do is to compress and zip it. So right now I am iterating through each row of a DataTable, adding appropriate commas, and streaming it out. It results in a .bin file with the data. By adding a name as an Attachment argument it sends to the client as a valid csv file. mail.Attachments.Add(new Attachment(stream, "report.csv")); Can

ASP.NET MailMessage.BodyEncoding and MailMessage.SubjectEncoding defaults

六月ゝ 毕业季﹏ 提交于 2019-12-10 23:12:28
问题 Simple question but I can't find the answer anywhere on MSDN... Looking for the defaults ASP.NET will use for: MailMessage.BodyEncoding and MailMessage.SubjectEncoding If you don't set them in code? Thanks 回答1: For MailMessage.BodyEncoding MSDN says: The value specified for the BodyEncoding property sets the character set field in the Content-Type header. The default character set is "us-ascii" . For MailMessage.SubjectEncoding I was also unable to find any documented default value, but

MailMessage Attachment filename with accents

天涯浪子 提交于 2019-12-10 13:17:36
问题 I'm trying to send HTML e-mails with attached Excel filenames. It all worked well until I neded to send messages whose attachment name contains accented letters :-( Every workaround I've tried failed miserably. Original code: var attachment = new Attachment( new MemoryStream(excelFileContents), "simplefilename.xls"); This one works fine. However if I replace "simplefilename.xls" by "échec.xls", the attachment is garbaged (name and contents). I tried these, to no avail: var attachment = new

Erroneous email receiver display when using German umlauts and a comma in name

拜拜、爱过 提交于 2019-12-10 03:22:53
问题 Using the MailMessage class in .NET 4, I found an issue today that I'm unable to resolve so far. Please see the following code: using (var message = new MailMessage()) { message.From = new MailAddress(@"uwe.keim@gmail.com", "Uwe Keim"); message.Bcc.Add(new MailAddress(@"uk@zeta-software.de", "Uwe Keim")); // This fails (see screenshot). /*1*/ message.To.Add(new MailAddress(@"uk2@zeta-sw.net", "Müller, Fred")); // This succeeds. /*2*/ message.To.Add(new MailAddress(@"uk2@zeta-sw.net", "Fred

Using MailMessage to send emails in C#

老子叫甜甜 提交于 2019-12-07 06:15:40
问题 I am experiencing some problems sending emails with MailMessage. I have two email accounts, (account1@gmail.com, and account2@gmail.com) and I would like account2 to send an email to account one at a button click event. This is what I have but it's not working. I'm getting and exception saying it's forbidden. try { //do submit MailMessage emailMessage = new MailMessage(); emailMessage.From = new MailAddress("account2@gmail.com", "Account2"); emailMessage.To.Add(new MailAddress("account1@gmail

Serialize a FileStream for transport

馋奶兔 提交于 2019-12-05 19:54:22
See also this question: 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, what is the best way to pass one or more Attachments to a WCF service? Alright I've solved this myself. The trick here is to convert the attachment to a Base64 encodes string, much the same way email systems do this. I've created a class to handle this. Posted here for others: [DataContract] public