G
Guest
Hi All,
I have a problem with my Attachment. The path is ok and everything work
without any error. But when i add the attachment by my input file, the form
is send to the email but the attachment is not with the mail.
it should be
Why it's not the case?
There is my code:
Sub Button1_Click(sender As Object, e As EventArgs)
Dim mailMessage As System.Web.Mail.MailMessage = New
System.Web.Mail.MailMessage
Dim objAttach As System.Web.Mail.MailAttachment
Dim postedFile = txtAttachment.PostedFile
Dim strPath As String = ""
Try
strPath = Path.GetFullPath(txtAttachment.postedFile.FileName)
Catch
End Try
mailMessage.From = "(e-mail address removed)"
mailMessage.To = "(e-mail address removed)"
mailMessage.Subject = "test"
mailMessage.BodyFormat = System.Web.Mail.MailFormat.html
mailMessage.Body = "test"
Try
objAttach = New System.Web.Mail.MailAttachment(strPath)
mailMessage.Attachments.Add(objAttach)
Catch
End Try
System.Web.Mail.SmtpMail.SmtpServer = "127.0.0.1"
System.Web.Mail.SmtpMail.Send(mailMessage)
End Sub
I have a problem with my Attachment. The path is ok and everything work
without any error. But when i add the attachment by my input file, the form
is send to the email but the attachment is not with the mail.
it should be
Why it's not the case?
There is my code:
Sub Button1_Click(sender As Object, e As EventArgs)
Dim mailMessage As System.Web.Mail.MailMessage = New
System.Web.Mail.MailMessage
Dim objAttach As System.Web.Mail.MailAttachment
Dim postedFile = txtAttachment.PostedFile
Dim strPath As String = ""
Try
strPath = Path.GetFullPath(txtAttachment.postedFile.FileName)
Catch
End Try
mailMessage.From = "(e-mail address removed)"
mailMessage.To = "(e-mail address removed)"
mailMessage.Subject = "test"
mailMessage.BodyFormat = System.Web.Mail.MailFormat.html
mailMessage.Body = "test"
Try
objAttach = New System.Web.Mail.MailAttachment(strPath)
mailMessage.Attachments.Add(objAttach)
Catch
End Try
System.Web.Mail.SmtpMail.SmtpServer = "127.0.0.1"
System.Web.Mail.SmtpMail.Send(mailMessage)
End Sub