相关疑难解决方法(0)

将MailMessage转换为原始文本

有没有简单的方法将System.Net.Mail.MailMessage对象转换为原始邮件消息文本,就像在记事本中打开eml文件一样.

.net c#

13
推荐指数
2
解决办法
9883
查看次数

将MailMessage发送到Exchange Server并发送到SMTP服务器之间的区别

我正在尝试使用MailMessage类来构建传输到SMTP服务器以使用SmtpClient类传递的电子邮件.我的电子邮件是通过Exchange服务器在outlook上配置的.关于上述实施,我有以下疑问:

1)Exchange Server和SMTP服务器之间有什么区别?

2)在我的情况下,我的Outlook使用我的凭据在Exchange服务器上配置.如何找到SMTP地址,以便我能够实现MailMessage类?

3)如果上述实施技术不可行,是否有基于交换服务器通过应用程序发送电子邮件的想法?

我正在使用Visual Studio 2008,框架3.5 SP1,使用C#作为语言处理winforms应用程序.请帮我澄清疑惑.

编辑

我使用以下代码.它不会抛出任何错误,也不会产生任何错误.我试图发送电子邮件给自己,但无济于事

public static void CreateMessageWithAttachment(string server)
    {
        // Specify the file to be attached and sent.
        // This example assumes that a file named Data.xls exists in the
        // current working directory.
        string file = "data.xls";
        // Create a message and set up the recipients.
        MailMessage message = new MailMessage(
           "ben@contoso.com",
           "ben@contoso.com",
           "Quarterly data report.",
           "See the attached spreadsheet.");

        // Create  the file attachment for this e-mail message. …
Run Code Online (Sandbox Code Playgroud)

c# exchange-server smtpclient exchangewebservices

5
推荐指数
1
解决办法
8014
查看次数

MailKit-MimeKit - 如何复制到“已发送”文件夹

我能够使用 MailKit 和 MimeKit 发送 SMTP 电子邮件,而 Outlook 是接收这些邮件的客户端工具。下面的代码已被使用,我的收件箱已收到电子邮件。

var email = new MimeMessage
{
    Sender = MailboxAddress.Parse("<<from>>")
};
email.To.Add(MailboxAddress.Parse("<<to>>"));

email.Subject = "Test mail from Jaish";
var builder = new BodyBuilder();
builder.TextBody = "This is a test mail from Jaish Mathews";
email.Body = builder.ToMessageBody();

using var smtp = new SmtpClient();
smtp.LocalDomain = "<<domain>>";
smtp.Timeout = 10000;

smtp.Connect("<<host>>", 25, SecureSocketOptions.None);
var mailboxes = email.To.Mailboxes;
//Sending email
await smtp.SendAsync(email);
//Disconnecting from smtp
smtp.Disconnect(true);
Run Code Online (Sandbox Code Playgroud)

问题是我的“已发送”文件夹没有记录这些已发送的电子邮件。如何手动复制到我的“已发送”文件夹”

c# mailkit .net-core mimekit .net-5

1
推荐指数
1
解决办法
2410
查看次数