我有这个样本C#代码,用于通过Windows-Mobile 6.5发送邮件:
EmailMessage message = new EmailMessage();
Recipient myrecipient = new Recipient("Gmail", "MyMail@gmail.com");
message.To.Add(myrecipient);
message.Subject = "test from Windows-Mobile";
message.BodyText = "this is the test from Windows-Mobile";
message.Send("Gmail");
MessagingApplication.Synchronize("Gmail");
SetForegroundWindow(this.Handle);
如何发送多个邮件地址?
如何将文本文件附加到邮件?
答案 0 :(得分:1)
试试这个:
附加包含名称/尺寸等详细信息的文件。
Attachment attachment = new Attachment(outputFile, MediaTypeNames.Text.Html);
ContentDisposition disposition = attachment.ContentDisposition;
disposition.CreationDate = File.GetCreationTime(outputFile);
disposition.ModificationDate = File.GetLastWriteTime(outputFile);
disposition.ReadDate = File.GetLastAccessTime(outputFile);
disposition.FileName = Path.GetFileName(outputFile);
disposition.Size = new FileInfo(outputFile).Length;
disposition.DispositionType = DispositionTypeNames.Attachment;
message.Attachments.Add(attachment);
smtp.Send(message);
链接为ref:
https://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.attachments%28v=vs.110%29.aspx
答案 1 :(得分:0)
EmailMessage message = new EmailMessage();
Recipient myrecipient = new Recipient("Gmail", "MyMail@gmail.com");
message.To.Add(myrecipient);
//Adding more To address
message.To.Add(myrecipient2);
message.To.Add(myrecipient3);
//Adding more CC address
message.Cc.Add(myrecipient4);
message.Cc.Add(myrecipient5);
//Adding more Bcc address
message.Bcc.Add(myrecipient6);
message.Bcc.Add(myrecipient7);
message.Subject = "test from Windows-Mobile";
message.BodyText = "this is the test from Windows-Mobile";
//Adding attachments
message.Attachments.Add("TextFilePath");
message.Send("Gmail");
MessagingApplication.Synchronize("Gmail");
SetForegroundWindow(this.Handle);