Call this function, if you are using VB.NET, can be converted to C#
Public Function SendEmailMessage(ByVal FromAddress As String, _
ByVal FromName As String, _
ByVal ToAddress As String, _
ByVal strSubject As String, _
ByVal strMessage As String, _
ByVal Attachment As String) As String
Dim oMAIL As New System.Net.Mail.MailMessage
Dim oSMTP As New System.Net.Mail.SmtpClient
SendEmailMessage = ""
oSMTP.Credentials = New System.Net.NetworkCredential("USERNAME", "PASSWORD")
oSMTP.Host = "SMTP HOST"
oSMTP.Port = 25
Try
oMAIL.From = New System.Net.Mail.MailAddress(FromAddress, FromName, System.Text.Encoding.UTF8)
Catch ex As Exception
Return Err.Description
End Try
If Len(ToAddress) > 0 Then
oMAIL.To.Add(ToAddress)
oMAIL.Subject = strSubject
oMAIL.Body = strMessage
Try
If Len(Attachment) > 0 Then
Dim oAttachment As New System.Net.Mail.Attachment(Attachment)
oMAIL.Attachments.Add(oAttachment)
End If
oMAIL.ReplyTo = New System.Net.Mail.MailAddress(FromAddress)
oSMTP.Send(oMAIL)
SendEmailMessage = "Success"
Catch ex As Exception
SendEmailMessage = Err.Description
End Try
End If
oSMTP = Nothing
oMAIL = Nothing
Return SendEmailMessage
End Function