This commit is contained in:
Digital Data - Marlon Schreiber 2019-03-14 22:28:37 +01:00
parent fcd44e78ff
commit fb142d4cef
2 changed files with 23 additions and 25 deletions

View File

@ -134,10 +134,14 @@ Public Class MyComService
oAttachment = String.Empty
Else
oAttachment = oEmail_Row.Item("EMAIL_ATTMT1")
If File.Exists(oAttachment) = False Then
_Logger.Warn($"Email Attachment FileNotFound Exception!")
Exit Sub
Else
_Logger.Info("Email Attachment is: {0}", oAttachment.ToString)
End If
End If
_Logger.Debug("Email Attachment is: {0}", oAttachment.ToString)
Dim link As String = "pmo://" & oJOB_ID & "-" & oEmail_Row.Item("REFERENCE1")
If oBody.Contains("[%PMOLINK_GER]") Then
oBody = oBody.Replace("[%PMOLINK_GER]", "<a href=""" & link & """>hier</a>")
@ -147,9 +151,7 @@ Public Class MyComService
oBody = oBody.Replace("[%PMOLINK_US]", "<a href=""" & link & """>here</a>")
End If
If _Email.NewEmail(oEmailTo, oSubject, oBody, oMailFrom, oMailSMTP, oMailport, oMailUser, oMailPW, oAuthType, "DDEDMI_ComService", oAttachment) = True Then
If _Email.NewEmail(oEmailTo, oSubject, oBody, oMailFrom, oMailSMTP, oMailport, oMailUser, oMailPW, oAuthType, "DDEDMI_ComService", oAttachment.ToString) = True Then
Dim upd = "UPDATE TBEDM_EMAIL_QUEUE SET EMAIL_SENT = CURRENT_TIMESTAMP WHERE GUID = " & oGUID
_firebird.ExecuteNonQuery(upd)
End If

View File

@ -131,7 +131,7 @@ Public Class Email
End Function
Public Function NewEmail(mailto As String, mailSubject As String, mailBody As String,
mailfrom 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 = "", Optional Test As Boolean = False)
AUTH_TYPE As String, SENDER_INSTANCE As String, Optional attachmentString As String = "", Optional Test As Boolean = False)
Try
Dim oError As Boolean = False
Dim oReceipiants As String()
@ -177,25 +177,21 @@ Public Class Email
Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(mymesssage.Body)
htmlView.ContentType = New System.Net.Mime.ContentType("text/html")
mymesssage.AlternateViews.Add(htmlView)
attment = attment.Replace("W:\", "\\windream\objects\")
If attment <> String.Empty Then
If System.IO.File.Exists(attment) Then
_logger.Info("Attachment Path is: {0}", attment)
Dim oAttachment As New System.Net.Mail.Attachment(attment)
_logger.Debug($"attachmentString [{attachmentString}]")
If attachmentString <> "" Then
_logger.Info($"Attachment Path is: {attachmentString}")
Dim oAttachment As New System.Net.Mail.Attachment(attachmentString)
'If attment.ToLower.EndsWith("pdf") Then
' oAttachment.ContentType = New Independentsoft.Email.Mime.ContentType("application", "pdf")
'ElseIf attment.ToLower.EndsWith("jpg") Then
' oAttachment.ContentType = New Independentsoft.Email.Mime.ContentType("application", "jpg")
'ElseIf attment.ToLower.EndsWith("docx") Then
' oAttachment.ContentType = New Independentsoft.Email.Mime.ContentType("application", "MS-word")
'End If
mymesssage.Attachments.Add(oAttachment)
Else
_logger.Warn($"Attachment {attment.ToString} is not existing - Mail won't be send!")
oError = True
End If
'If attment.ToLower.EndsWith("pdf") Then
' oAttachment.ContentType = New Independentsoft.Email.Mime.ContentType("application", "pdf")
'ElseIf attment.ToLower.EndsWith("jpg") Then
' oAttachment.ContentType = New Independentsoft.Email.Mime.ContentType("application", "jpg")
'ElseIf attment.ToLower.EndsWith("docx") Then
' oAttachment.ContentType = New Independentsoft.Email.Mime.ContentType("application", "MS-word")
'End If
mymesssage.Attachments.Add(oAttachment)
Else
_logger.Debug("No Attachment.")
End If
_logger.Debug($"mailfrom [{mailfrom}]")