Send File With attatchement Link in E-Mail

25 May

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()
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
End If
Catch ex As Exception
‘return nothing
End Try
End Sub

Leave a comment

Posted by on May 25, 2011 in Vb.Net


Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: