首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >opennetcf.net.mail附件帮助

opennetcf.net.mail附件帮助
EN

Stack Overflow用户
提问于 2011-08-24 01:54:33
回答 2查看 1.8K关注 0票数 1

感谢您关注我的问题。

我正在尝试找出OpenNetCF.Net.Mail的附件。下面是我的SendMail函数的代码:

代码语言:javascript
复制
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();
    }
}

这应该是一个问题,通过以下方式调整它,以允许附件:

代码语言:javascript
复制
Attachment myAttachment = new Attachment();
message.Attachments.Add(myAttachment);

问题是我不知道如何添加附件。上面的行应该是中间的其他东西,在那里我实际告诉它我想要附加的文件。在这件事上的任何帮助都将非常感谢。

再次感谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-08-24 12:03:41

根据此MSDN documentation,您可以将附件的文件名指定为参数。因此,您可以将fullpath作为字符串参数提供。

票数 0
EN

Stack Overflow用户

发布于 2012-06-22 10:06:42

他们有可以用来构建电子邮件附件的AttachmentBase。但是,我们不能将AttachmentBase实例添加到电子邮件的附件中。

我认为Attachment类应该继承自AttachmentBase。我认为这可能是一个缺陷。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7165390

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档