peebman2000
Programmer
Hello everyone, if you are familar with my username Peebman2000, i'm a beginner programmer with alot of questions. Anyway below is my code to send emails with an attachment. Where I declare "mailmsg as new mailmessage(textemail.text, toaddress)", i'm getting an error message of "type 'MailMessage' is not defined". Its defined and I don't know why I'm getting this message. Does anyone know why and have a suggestion on how I can get it right? Thanks.
Imports System
Imports System.IO
Imports System.Text
Imports System.Threading
Partial Class _Default
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 Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tsmtpserver As String
tsmtpserver = "smtp.odn.state.oh.us"
Dim space As String = " "
Dim toaddress As String = textemail.Text
'mystring = textemail.Text
'lblemail.Text = mystring
Dim mailmsg As New MailMessage(textemail.Text, toaddress)
'Dim mailmsg As New System.Net.Mail.MailMessage
'Dim attachname As String
'mailmsg.From = textemail.Text
'mailmsg.To.add(textemail.Text, "")
'mailmsg.fromaddress = "david.peebles@das.state.oh.us"
'mailmsg.fromname = "david"
'mailmsg.bodytext = "this is a test dummy, Notre Dame are losers"
'mailmsg.subject = "test"
mailmsg.textfirst.text += "My First Name:" + space + space + textfirst.Text
mailmsg.textlast.text += "My Last Name:" + space + space + textlast.Text
If Not (FileUpload1.PostedFile Is Nothing) And FileUpload1.PostedFile.FileName <> "" Then
Dim fileName = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName)
mailmsg.Attachments.Add(FileUpload1.PostedFile.InputStream, fileName)
End If
End Sub
Private Function GetDomain(ByVal email As String) As String
Dim index = email.IndexOf("@")
Return email.Substring(index + 1)
End Function
End Class
Imports System
Imports System.IO
Imports System.Text
Imports System.Threading
Partial Class _Default
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 Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tsmtpserver As String
tsmtpserver = "smtp.odn.state.oh.us"
Dim space As String = " "
Dim toaddress As String = textemail.Text
'mystring = textemail.Text
'lblemail.Text = mystring
Dim mailmsg As New MailMessage(textemail.Text, toaddress)
'Dim mailmsg As New System.Net.Mail.MailMessage
'Dim attachname As String
'mailmsg.From = textemail.Text
'mailmsg.To.add(textemail.Text, "")
'mailmsg.fromaddress = "david.peebles@das.state.oh.us"
'mailmsg.fromname = "david"
'mailmsg.bodytext = "this is a test dummy, Notre Dame are losers"
'mailmsg.subject = "test"
mailmsg.textfirst.text += "My First Name:" + space + space + textfirst.Text
mailmsg.textlast.text += "My Last Name:" + space + space + textlast.Text
If Not (FileUpload1.PostedFile Is Nothing) And FileUpload1.PostedFile.FileName <> "" Then
Dim fileName = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName)
mailmsg.Attachments.Add(FileUpload1.PostedFile.InputStream, fileName)
End If
End Sub
Private Function GetDomain(ByVal email As String) As String
Dim index = email.IndexOf("@")
Return email.Substring(index + 1)
End Function
End Class