出于某种原因," 通过Gmail发送.NET中的电子邮件 "既没有被接受的答案也没有其他任何一个对我有用.他们为什么不工作?
更新:我在另一个问题中尝试了所有答案(接受和否则),但没有一个能够奏效.
我想知道它是否适用于其他任何人,否则谷歌可能已经改变了一些事情(之前发生过).
当我尝试使用的代码片段时SmtpDeliveryMethod.Network,我会在Send(消息)上快速收到SmtpException.信息是
SMTP服务器需要安全连接或客户端未经过身份验证.
服务器响应是:
5.5.1需要验证.了解更多"< - 认真,它在那里结束.
更新:
这是我很久以前问过的一个问题,接受的答案是我在不同的项目中使用了很多次的代码.
我已经在这篇文章和其他EmailSender项目中采用了一些想法,在Codeplex上创建了一个EmailSender项目.它专为可测试性而设计,支持我最喜欢的SMTP服务,如GoDaddy和Gmail.
我可以让Web应用程序使用Windows任务计划程序发送自动电子邮件.现在我想使用我为发送电子邮件而编写的以下方法发送HTML格式的电子邮件.
我的代码隐藏:
protected void Page_Load(object sender, EventArgs e)
    {
        SmtpClient sc = new SmtpClient("mail address");
        MailMessage msg = null;
        try
        {
            msg = new MailMessage("xxxx@gmail.com",
                "yyyy@gmail.com", "Message from PSSP System",
                "This email sent by the PSSP system");
             sc.Send(msg);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            if (msg != null)
            {
                msg.Dispose();
            }
        }
    }
怎么做?我只想在电子邮件中添加一些带有一个链接和一个图像的粗体文本.
My Rails 3应用程序以纯文本和HTML格式发送电子邮件.我使用RoundCube和Squirrel Mail客户端在本地测试了它们,它们都显示带有图像,链接等的HTML版本.另一方面,GMail选择纯文本格式.知道是什么导致了这个吗?
Delivered-To: test@gmail.com
Received: by 10.42.166.2 with SMTP id m2cs16081icy;
        Thu, 3 Mar 2011 17:01:48 -0800 (PST)
Received: by 10.229.211.138 with SMTP id go10mr1544841qcb.195.1299200507499;
        Thu, 03 Mar 2011 17:01:47 -0800 (PST)
Return-Path: <info@example.com>
Received: from beta.example.com (testtest.test.com [69.123.123.123])
        by mx.google.com with ESMTP id j14si1690118qcu.136.2011.03.03.17.01.46;
        Thu, 03 Mar 2011 17:01:46 -0800 (PST)
Received-SPF: neutral (google.com: 69.123.123.123 is neither permitted nor denied by best guess record for domain of info@example.com) client-ip=69.123.123.123;
Authentication-Results: mx.google.com; spf=neutral (google.com: 69.123.123.123 is neither permitted …是否可以使用C#中的asp.net项目从我的计算机(localhost)发送电子邮件?最后我要将我的项目上传到网络服务器,但我想在上传前测试它.
我找到了准备好的源代码并尝试在localhost中运行它们,但它们都没有成功运行.例如这段代码:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Net.Mail;
    namespace sendEmail
    {
        public partial class _default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
            }
            protected void Btn_SendMail_Click(object sender, EventArgs e)
            {
                MailMessage mailObj = new MailMessage(
                    txtFrom.Text, txtTo.Text, txtSubject.Text, txtBody.Text);
                SmtpClient SMTPServer = new SmtpClient("localhost");
                try
                {
                    SMTPServer.Send(mailObj);
                }
                catch (Exception ex)
                {
                    Label1.Text = ex.ToString();
                }
            }
        }
    }
那么如何使用asp.net C#发送电子邮件?我应该设置一些服务器配置吗?