Torna al Thread

Public Function SendEmailMessage(ByVal strNomeMittente As String, ByVal strFrom As String, ByVal strTo As String, ByVal strReplyTo As String, ByVal strSubject As String, _ ByVal strMessage As String, ByVal HTMLMode As Boolean, ByVal Host As String, ByVal file As String, ByVal UseSMTPAuth As Boolean, ByVal Username As String, ByVal Password As String) As Boolean Try Dim Email As New MailMessage(New MailAddress(strFrom, strNomeMittente), New MailAddress(strTo)) Dim mailClient As New SmtpClient(Host, CInt("25")) Dim Reply As New MailAddress(strReplyTo.Trim, strNomeMittente) Email.ReplyTo = Reply Email.Subject = strSubject Email.IsBodyHtml = HTMLMode Email.Body = strMessage If file <> Nothing Then Dim Allegato As New Attachment(file) Email.Attachments.Add(Allegato) End If If UseSMTPAuth = True Then Dim NetCredential As New Net.NetworkCredential(Username, Password) mailClient.Credentials = NetCredential Else mailClient.UseDefaultCredentials = True End If mailClient.Send(Email) mailClient.Timeout = 5000 Email.Dispose() Return True Catch ex As Exception Throw New Exception("Errore invio mail: " & ex.Message, ex) Return False End Try
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5