FileFlow/Global_Indexer/ClassEmail.vb
2021-03-01 12:33:41 +01:00

75 lines
3.8 KiB
VB.net

Imports System.Net.Mail
Public Class ClassEmail
Public Shared Function Send_Log_Mail(ByVal vBody As String, ByVal vBetreff As String, ByVal emailfrom As String, ByVal emailsmtp As String, ByVal emailuser As String, ByVal emailpw As String, ByVal email_empf As String, Optional test As Boolean = False, Optional Log As Boolean = False)
'#### E-MAIL NACHRICHT VERSENDEN
Try
Dim empfaenger As String()
If email_empf.Contains(";") Then
empfaenger = email_empf.Split(";")
Else
ReDim Preserve empfaenger(0)
empfaenger(0) = email_empf
End If
'Für jeden Empfänger eine Neue Mail erzeugen
For Each _mailempfaenger As String In empfaenger
' Neue Nachricht erzeugen:
Dim message As New MailMessage(emailfrom, _mailempfaenger, vBetreff & " - Domain: " & Environment.UserDomainName,
"<font face=""Arial"">" & vBody & "<br>>> Version: " & My.Application.Info.Version.ToString & "<br>>> Maschine: " & Environment.MachineName & "<br>" & "<br>>> Domain-Name: " & Environment.UserDomainName & "<br>" &
"<br>>> Gesendet am: " & My.Computer.Clock.LocalTime.ToShortDateString & " " &
My.Computer.Clock.LocalTime.ToLongTimeString & "</font>")
If test = False Then
If Log = True Then
' create and add the attachment(s) */
If ClassLogger.logDateiname.Contains("\\") Then
ClassLogger.logDateiname = ClassLogger.logDateiname.Replace("\\", "\")
End If
If IO.File.Exists(ClassLogger.logDateiname) Then
Dim Attachment As Attachment = New Attachment(ClassLogger.logDateiname)
message.Attachments.Add(Attachment)
End If
End If
End If
With message
.IsBodyHtml = True
.Priority = MailPriority.High
End With
'Einen SMTP Client erzeugen und Anmeldungsinformationen hinterlegen
Dim emailClient As New SmtpClient(emailsmtp)
'Email mit Authentifizierung
Dim SMTPUserInfo As New System.Net.NetworkCredential(emailuser, emailpw)
emailClient.UseDefaultCredentials = False
emailClient.Credentials = SMTPUserInfo
emailClient.Port = 25
'*Send the message */
emailClient.Send(message)
If USER_LANGUAGE = "de-DE" Then
If test = True Then
MsgBox("Die Test-Email wurde erfolgreich versendet!", MsgBoxStyle.Information, "Erfolgsmeldung:")
End If
If Log = True Then
MsgBox("Die Support-Email wurde erfolgreich versendet!", MsgBoxStyle.Information, "Erfolgsmeldung:")
End If
Else
If test = True Then
MsgBox("Test-Email sucessfully sent!", MsgBoxStyle.Information, "Success:")
End If
If Log = True Then
MsgBox("Support-Email sucessfully sent!", MsgBoxStyle.Information, "Success:")
End If
End If
'LOGGER.Info(">> Support/Log Email erfolgreich an " & _mailempfaenger & " versendet!")
Next
Return True
Catch ex As Exception
LOGGER.Info("### Fehler im Mailversand: " & ex.Message)
LOGGER.Error(ex)
Return False
End Try
End Function
End Class