谢谢你看我的问题。opennetcf.net.mail附件帮助
我想弄清楚OpenNetCF.Net.Mail的附件。这里是我的SendMail函数的代码:
public static void SendMessage(string subject,
string messageBody,
string fromAddress,
string toAddress,
string ccAddress)
{
MailMessage message = new MailMessage();
SmtpClient client = new SmtpClient();
MailAddress address = new MailAddress(fromAddress);
// Set the sender's address
message.From = address;
// Allow multiple "To" addresses to be separated by a semi-colon
if (toAddress.Trim().Length > 0)
{
foreach (string addr in toAddress.Split(';'))
{
message.To.Add(new MailAddress(addr));
}
}
// Allow multiple "Cc" addresses to be separated by a semi-colon
if (ccAddress.Trim().Length > 0)
{
foreach (string addr in ccAddress.Split(';'))
{
message.CC.Add(new MailAddress(addr));
}
}
// Set the subject and message body text
message.Subject = subject;
message.Body = messageBody;
// TODO: *** Modify for your SMTP server ***
// Set the SMTP server to be used to send the message
client.Host = "smtp.dscarwash.com";
string domain = "dscarwash.com";
client.Credentials = new SmtpCredential("mailuser", "dscarwash10", domain);
// Send the e-mail message
try
{
client.Send(message);
}
catch (Exception e)
{
string data = e.ToString();
}
}
它应该是通过以下方式调整它允许附件的问题:
Attachment myAttachment = new Attachment();
message.Attachments.Add(myAttachment);
的问题是,我无法弄清楚如何获取附件添加。上面的代码应该是中间的其他东西,我实际上告诉它我要附加的文件。任何有关此事的帮助将不胜感激。
再次感谢!
你的意思是你想要多个附件或类似的东西? –
只有一个附件,一个zip文件 – jnsohnumr
您使用什么代码来附加以及出现什么错误?还是说Attachment类没有向其中添加文件所需的API? – Quibblesome