呃,我已經完成了我的功課,甚至在這個網站上看過幾個例子,都無濟於事。我的程序旨在發送填寫在表單上的數據,並將其發送到電子郵件。我的其他代碼顯示沒有錯誤,除了SmptMailMessage之外。這裏是我的代碼:C#中的錯誤:無法找到類型或命名空間'SmptMailMessage'
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Mail;
namespace FPSArrestReport
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btn1_Click(object sender, EventArgs e)
{
SmtpClient SmptMailMessage = new SmtpClient();
SmptMailMessage mail = new SmtpMailMessage("smtp.gmail.com", 25); // error on this line
\\on the SmptMailmessage
//set the to address to the primary email
mail.To.Add("[email protected]");
//set the message type and subject and body
mail.IsHtmlMessage = true;
mail.Subject = "";
mail.Body = "Hello world!";
//send the email
mail.Send();
}
當您一貫使用'Smtp'而不是'Smpt'時,您的許多問題都會消失。 – spender
Noob here:你如何從cshtml頁面調用這個函數? –
哈哈,@宣傳。我注意到我正在使用stmp xD –