every time I declare a new MailMessage the page won't load, not matter what I've tried, I get a runtime error at every point, and there doesn't seem to be alot of help online for the system.net.mail class
my code so far, I haven't had the chance to test it as even the declaration causes a runtime error
all I need is the easiest way to send text and some pictures from an online form, if there is an easier way to do this that'd bef fine
sending just text through Dim objMailer As New System.Net.Mail.SmtpClient() works just fine, it's MailMessage that has problems for some reason.
my code bellow
Public Sub SendEmail(ByVal emailFrom As String, ByVal emailTo As String, ByVal emailSubject As String, ByVal emailBody As String)
Dim objMailer As New System.Net.Mail.SmtpClient()
Dim senMail As New System.Net.Mail.MailMessage()
objMailer.Host = 'myrelayserv.com' ' Your SMTP server
objMailer.Send(emailFrom, emailTo, emailSubject, emailBody)
End Sub
the rest of my code, right now it's all in comments as I can't get the mailmessage issue resolved, if you notice any problems in it please do let me know
Sub Submit_Form(ByVal Sender As Object, ByVal E As EventArgs)
'SendEmail(Me.email.Text, 'mail@school.edu', Me.name.Text, Me.ideas.Text)
'create the mail message
Dim senMail As New System.Net.Mail.MailMessage
'set the addresses
senMail.From = New MailAddress(Me.email.Text)
senMail.To.Add('mail@school.edu')
'set the content
senMail.Subject = Me.name.Text
senMail.Body = Me.ideas.Text
'add an attachment from the filesystem
senMail.Attachments.Add(New Attachment(FileUpload1.PostedFile.FileName))
''to add additional attachments, simply call .Add(...) again
''mail.Attachments.Add(New Attachment('c:\temp\example2.txt'))
''mail.Attachments.Add(New Attachment('c:\temp\example3.txt'))
''send the message
Dim smtp As New SmtpClient('myrelayserv.edu')
smtp.Send(senMail)
End Sub
by: imsolostPosted on 2006-02-20 at 08:41:41ID: 16001323
Does the page load at all? If not paste the entire page here please. If it does load and you run the code below do you get an error? if so what is the error.
u')
Dim smtp As New SmtpClient('myrelayserv.ed
smtp.Send(Me.email.Text, 'mail@school.edu', Me.name.Text, Me.ideas.Text)
What framework version are you using. You might also try a different SMTP as the one you are trying may require authentication to relay messages. There are some free SMTP services on the net you might try.