MS EmailFunctions
- ZuGferd Service - Windream
This commit is contained in:
@@ -261,6 +261,7 @@ Public Class Email
|
||||
AUTH_TYPE As String, SENDER_INSTANCE As String, Optional attachmentString As String = "", Optional Test As Boolean = False)
|
||||
Dim myClient As Net.Mail.SmtpClient
|
||||
Dim myMesssage As New MailMessage
|
||||
|
||||
Try
|
||||
Dim oError As Boolean = False
|
||||
Dim oReceipiants As String()
|
||||
@@ -361,7 +362,7 @@ Public Class Email
|
||||
|
||||
End Function
|
||||
Public Function New_EmailISoft(ByVal mailSubject As String, ByVal mailBody As String, mailto As String,
|
||||
mailfrom As String, mailsmtp As String, mailport As Integer, mailUser As String, mailPW As String,
|
||||
from_mailaddress As String, from_name As String, mailsmtp As String, mailport As Integer, mailUser As String, mailPW As String,
|
||||
AUTH_TYPE As String, SENDER_INSTANCE As String, Optional attment As String = "")
|
||||
Try
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
|
||||
@@ -378,16 +379,17 @@ Public Class Email
|
||||
For Each _mailempfaenger As String In empfaenger
|
||||
_logger.Debug($"Working on email for {_mailempfaenger}..")
|
||||
Try
|
||||
Dim message As New Message()
|
||||
message.From = New Mailbox(mailfrom, mailfrom)
|
||||
message.[To].Add(New Mailbox(_mailempfaenger))
|
||||
message.Subject = mailSubject
|
||||
Dim oMessage As New Message()
|
||||
oMessage.From = New Mailbox(from_mailaddress, from_name)
|
||||
|
||||
oMessage.[To].Add(New Mailbox(_mailempfaenger))
|
||||
oMessage.Subject = mailSubject
|
||||
_logger.Debug($"Message created..")
|
||||
Dim textBodyPart As New BodyPart()
|
||||
textBodyPart.ContentType = New ContentType("text", "html", "utf-8")
|
||||
textBodyPart.ContentTransferEncoding = ContentTransferEncoding.QuotedPrintable
|
||||
textBodyPart.Body = mailBody
|
||||
message.BodyParts.Add(textBodyPart)
|
||||
oMessage.BodyParts.Add(textBodyPart)
|
||||
If attment <> String.Empty Then
|
||||
If System.IO.File.Exists(attment) Then
|
||||
Dim attachment1 As New Independentsoft.Email.Mime.Attachment(attment)
|
||||
@@ -398,7 +400,7 @@ Public Class Email
|
||||
ElseIf attment.ToLower.EndsWith("docx") Then
|
||||
attachment1.ContentType = New ContentType("application", "MS-word")
|
||||
End If
|
||||
message.BodyParts.Add(attachment1)
|
||||
oMessage.BodyParts.Add(attachment1)
|
||||
Else
|
||||
_logger.Warn($"Attachment {attment.ToString} is not existing!")
|
||||
End If
|
||||
@@ -469,7 +471,7 @@ Public Class Email
|
||||
End Try
|
||||
End Try
|
||||
Try
|
||||
client.Send(message)
|
||||
client.Send(oMessage)
|
||||
_logger.Info("Message to " & _mailempfaenger & " has been send.")
|
||||
_error = False
|
||||
Catch ex As Exception
|
||||
|
||||
Reference in New Issue
Block a user