My webform will send an e-mail, but error's out when there is an attachment.(Invalid mail attachment ''.)
some code:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim path As String = Server.MapPath(path)
Dim file As String = System.IO.Path.GetFileName(fileUploader.PostedFile.FileName)
filename = path + "\" + file
fileUploader.PostedFile.SaveAs(filename)
temp.Text = filename
End Sub
Private Button2_click()
Dim mymessage As Mail.MailMessage
mymessage.From = "[email protected]"
mymessage.To = "[email protected]"
mymessage.Subject = "New Applicant Information"
mymessage.Priority = MailPriority.High
mymessage.BodyFormat = MailFormat.Text
mymessage.Body = "This is a test"
SmtpMail.SmtpServer = "mail1.work.org"
Dim myAttachment = New MailAttachment(filename, MailEncoding.UUEncode)
mymessage.Attachments.Add(myAttachment)
SmtpMail.Send(mymessage)
end sub
What am I missing here to make this not work???