Hi all
Iam trying to code my Email web form to enable it to send emails . The code seems correct except that I get an error when declaring mailMessage
as in Dim MM as MailMessage
MailMessage is underlined and Iam getting an error saying "MailMessage is ambigious" and something about a namespace. Here is my code below please assist?
Imports System
Imports System.Web.Mail
Imports System.Net.Mail
Imports System.Net
Imports Microsoft.SqlServer
Imports System.Net.Mail.MailMessage
Imports System.Data.SqlClient
Imports System.Web.Profile
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.IO
Imports System.Net.Mail.SmtpClient
Partial Class Email
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim MySmtpClient As New SmtpClient
Dim MM As New MailMessage()
MySmtpClient.Host = "Tinashe -pc."
MySmtpClient.Port = 25
'Dim fromAddress As New MailAddress '("
[email protected]","Tinahse ")
MM.From = TextBox1.Text
MM.To = "
[email protected]"
'you also can set this to TextBox2.Text
MM.Cc = TextBox3.Text
MM.Bcc = TextBox4.Text
MM.Subject = TextBox5.Text
MM.BodyFormat = TextBox7.Text
MM.Body = TextBox6.Text
'textbox6 TextMode property is set to MultiLine
MM.Priority = MailPriority.Normal
MySmtpClient.SmtpServer = "mail.tinashe-pc.com"
'mail server used to send this email. modify this line based on your mail server
MySmtpClient.Send(MM)
Label6.Text = "Your mail was sent"
'message stating the mail is sent
End Sub
End Class