我有一個網頁,在聯繫我們選項卡我有一個表格用戶只能輸入他們的姓名,電子郵件ID,主題和消息。一旦他們點擊確定按鈕,我想將這些消息發送到我的Hotmail帳戶。如何使用asp.net發送消息到hotmail而無需用戶密碼?
我試了一些代碼。但它不起作用。
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential(txtUserEmail.text, txtPassword);
smtp.EnableSsl = true;
MailMessage msg = new MailMessage();
msg.Subject = "Demo";
msg.Body = "Hi there..";
string toAddress = "[email protected]"; // Add Recepient address
msg.To.Add(toAddress);
string fromAddress = "\"no reply \" <[email protected]>";
msg.From = new MailAddress(fromAddress);
msg.IsBodyHtml = true;
try
{
smtp.Send(msg);
}
catch
{
throw;
}
我試過這段代碼。但它有一個密碼。我希望用戶在沒有密碼,請發送電子郵件至我[email protected]
這裏是我的外形設計
這個問題**很不明確**,代碼沒有多大意義。如果用戶與您聯繫,那麼電子郵件地址將嵌入數據中,用戶將不會發送郵件,而是將數據形成到服務器,然後服務器會向您發送電子郵件。 **憑據和地址將是服務器上您的電子郵件帳戶**。 如果您希望用戶發送電子郵件,那麼它將通過其客戶端電子郵件程序... – Phil1970