General information
Title:
Errors (Invalid email attachment)
I used below codes for sending email thru asp.net, everything goes ok if I send email without file attachment.. and I will met error "Invalid mail attachment" If file attached ..am I missing something inside the codes? ..
could any body please help me ? .. many thanks in advance
Imports System.Web.Mail
Public Sub SendEmail(ByVal pTo As String, ByVal pSubject As String, ByVal pBody As String, ByVal pAttachment As String)
Dim objMail
Dim mailMessage As New MailMessage()
Dim mFrom As String
Dim mSMTPServer As String
mSMTPServer = ConfigurationSettings.AppSettings("mSMTPServerName")
mFrom = ConfigurationSettings.AppSettings("mFromForgotPassword")
If Len(Trim(mSMTPServer)) > 0 And Len(Trim(mFrom)) > 0 Then
mailMessage.From = mFrom
mailMessage.To = pTo
mailMessage.Subject = pSubject
mailMessage.BodyFormat = Mail.MailFormat.Text
mailMessage.Body = pBody
If Len(Trim(pAttachment)) > 0 Then
Dim mAttachment As New MailAttachment("C:\WINAN1.TXT")
mailMessage.Attachments.Add(mAttachment)
End If
SmtpMail.SmtpServer = mSMTPServer
SmtpMail.Send(mailMessage)
End If
End Sub
Regards
Winan
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only