RSS

Tag Archives: Send Mail with file attatchement Link

Send File With attatchement Link in E-Mail


Public Sub SendEmail(ByVal EmailTo As String, ByVal EmailCC As String, ByVal EmailBCC As String, ByVal EmailSubject As String, ByVal EmailBody As String, ByVal EmailFrom As String)
Dim smtpClient As New SmtpClient()
Try
If AppSettings(“ServerName”) <> “” Then
smtpClient.Host = AppSettings(“ServerName”)
If (AppSettings(“ServerName”).Length > 0) Then
smtpClient.Port = AppSettings(“smtpPort”)
End If
If (AppSettings(“smtpUser”).Length > 0) Then
smtpClient.Credentials = New NetworkCredential(AppSettings(“smtpUser”), AppSettings(“smtpPassword”))
End If
Dim emailMessage As New MailMessage()
emailMessage.To.Add(New MailAddress(EmailTo))
If EmailCC <> “” Then
emailMessage.CC.Add(New MailAddress(EmailCC))
End If
If EmailBCC <> “” Then
emailMessage.Bcc.Add(New MailAddress(EmailBCC))
End If
‘smtpClient.DeliveryMethod = smtpClient.PickupDirectoryLocation

emailMessage.From = New MailAddress(EmailFrom)
emailMessage.Body = EmailBody
emailMessage.Subject = EmailSubject
emailMessage.IsBodyHtml = True
emailMessage.Priority = MailPriority.Normal
If Not fu_Resume Is Nothing Then
If fu_Resume.HasFile Then
emailMessage.Attachments.Add(New Attachment(fu_Resume.PostedFile.InputStream, fu_Resume.FileName))
End If
End If
‘For Coverletter Attachement
If Not fu_CoverLetter Is Nothing Then
If fu_CoverLetter.HasFile Then
emailMessage.Attachments.Add(New Attachment(fu_CoverLetter.PostedFile.InputStream, fu_CoverLetter.FileName))
End If
End If
smtpClient.Send(emailMessage)
End If
Catch ex As Exception
‘Response.Redirect(“ErrorPage.aspx”)
‘return nothing
End Try
End Sub

 
Leave a comment

Posted by on May 25, 2011 in Vb.Net

 

Tags: ,