我写了一个C#程序来发送一封完美的电子邮件.另外,我有一个PHP脚本来发送电子邮件,它也很好用.
但我的问题是:是否可以像使用PHP一样发送带有C#的电子邮件,而不需要指定凭据,服务器,端口等.
我想使用C#而不是PHP,因为我正在创建一个ASP.Net Web应用程序.
这是我目前的C#代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Mail;
using System.Net;
namespace $rootnamespace$
{
public partial class $safeitemname$ : Form
{
public $safeitemname$()
{
InitializeComponent();
}
private void AttachB_Click(object sender, EventArgs e)
{
if (AttachDia.ShowDialog() == DialogResult.OK)
{
string AttachF1 = AttachDia.FileName.ToString();
AttachTB.Text = AttachF1;
AttachPB.Visible = true;
AttachIIB.Visible = true;
AttachB.Visible = false;
}
}
private void AttachIIB_Click(object sender, EventArgs e)
{
if …Run Code Online (Sandbox Code Playgroud)