C# opennetcf.net.mail附件帮助
谢谢你看我的问题 我正在尝试找出OpenNetCF.Net.Mail的附件。以下是my SendMail功能的代码:C# opennetcf.net.mail附件帮助,c#,compact-framework,windows-ce,opennetcf,smart-device-framework,C#,Compact Framework,Windows Ce,Opennetcf,Smart Device Framework,谢谢你看我的问题 我正在尝试找出OpenNetCF.Net.Mail的附件。以下是my SendMail功能的代码: public static void SendMessage(string subject, string messageBody, string fromAddress, string toAddress, string ccAddress) { MailMessage message = new MailMessage(); SmtpC
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);
问题是我不知道如何添加附件。上面的线条应该是中间的一些东西,我实际上告诉它我想要附加什么文件。在此问题上的任何帮助都将不胜感激
再次感谢 根据此MSDN,您可以将附件的文件名指定为参数。因此,您可以将fullpath作为字符串参数。他们有
AttachmentBase
,可用于构建电子邮件附件。但是,我们无法将AttachmentBase
的实例添加到电子邮件的附件中
我认为
Attachment
类应该继承自AttachmentBase
。我认为这可能是一个缺陷。你的意思是你想要多个附件或类似的东西吗?只有一个附件,一个zip文件。你用什么代码来附加附件,你会遇到什么错误?或者是附件类没有添加文件所需的API?附件类似乎没有我需要的一切。我无法找到如何实际指示我要附加的文件名和路径。我尝试使用PocketOutlook附件类和强制转换,但无法进行转换。是的,我能够做到,但问题是我不能将PocketOutlookAttachment转换为opennetcf.net.mail附件,这正是我实际需要的。@jnsohunmr,社区论坛上的一个旧线程表明这是一个bug。看起来他们从未纠正过这个错误。请看这里:感谢最终使用了链接到其他地方的商业产品:主要的“缺陷”是我们从未实现过附件。如果你看一下源代码,就会发现它完全被删掉了。我曾经考虑过实现它——事实上有好几次——但现实是,我仍然可以一方面计算得到的请求数量,而且我总是有很多事情要做。也许对于CF的下一个版本,我将重新访问它。