相关疑难解决方法(0)

通过Gmail在.NET中发送电子邮件

我没有依赖我的主机发送电子邮件,而是考虑使用我的Gmail帐户发送电子邮件.这些电子邮件是我在节目中播放的乐队的个性化电子邮件.有可能吗?

.net c# email gmail smtp

852
推荐指数
18
解决办法
53万
查看次数

发送带附件的邮件

编辑:我可以发送没有附件的邮件

尝试发送邮件时出现此错误:

System.Net.Mail.SmtpException: The operation has timed out.
Run Code Online (Sandbox Code Playgroud)

以下是我的代码:

public static void SendMailMessage(string to, string subject, string body, List<string> attachment)
{
    MailMessage mMailMessage = new MailMessage();
    // string body; --> Compile time error, body is already defined as an argument

    mMailMessage.From = new MailAddress("abc@gmail.com");

    mMailMessage.To.Add(new MailAddress(to));

    mMailMessage.Subject = subject;

    mMailMessage.Body = body;

    foreach (string s in attachment)
    {
        var att = new Attachment(s);

        mMailMessage.Attachments.Add(att);

    }


    // Set the format of the mail message body as HTML
    mMailMessage.IsBodyHtml = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net

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

标签 统计

c# ×2

.net ×1

asp.net ×1

email ×1

gmail ×1

smtp ×1