This commit is contained in:
Digital Data - Marlon Schreiber 2019-04-16 08:10:49 +02:00
parent fb142d4cef
commit 15d688cc89
6 changed files with 47 additions and 58 deletions

View File

@ -31,6 +31,9 @@
<setting name="JOB_INTERVAL" serializeAs="String">
<value>10</value>
</setting>
<setting name="MSSQL_CONNECTION" serializeAs="String">
<value>Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM;Persist Security Info=True;User ID=sa;Password=ddd</value>
</setting>
</DDZUGFeRDService.My.MySettings>
</applicationSettings>
</configuration>

View File

@ -116,6 +116,16 @@ Namespace My
Return CType(Me("JOB_INTERVAL"),Integer)
End Get
End Property
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM;Persist Security Info=True;"& _
"User ID=sa;Password=ddd")> _
Public ReadOnly Property MSSQL_CONNECTION() As String
Get
Return CType(Me("MSSQL_CONNECTION"),String)
End Get
End Property
End Class
End Namespace

View File

@ -23,5 +23,8 @@
<Setting Name="JOB_INTERVAL" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">10</Value>
</Setting>
<Setting Name="MSSQL_CONNECTION" Type="System.String" Scope="Application">
<Value Profile="(Default)">Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM;Persist Security Info=True;User ID=sa;Password=ddd</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -164,7 +164,7 @@ Public Class frmEmailAccount
Dim PWPlain = wrapper.DecryptData(txtEMAIL_PW.Text)
If _Email.NewEmail(txtTestmail.Text, "Testmail DD Windream-ResultHandler", "This is the body (text will be replaced within profile)", txtEMAIL_FROM.Text, txtSERVER_OUT.Text, txtPORT_OUT.Text, txtEMAIL_USER.Text, PWPlain, cmbAUTH_TYPE.Text, "EDMI GUI") = True Then
If _Email.NewEmail(txtTestmail.Text, "Testmail", "This is the bodytext", txtEMAIL_FROM.Text, txtSERVER_OUT.Text, txtPORT_OUT.Text, txtEMAIL_USER.Text, PWPlain, cmbAUTH_TYPE.Text, "EDMI GUI") = True Then
MsgBox("Email was send successfully.", MsgBoxStyle.Information)
Else
MsgBox("Could not send the testmail. Please check the log.", MsgBoxStyle.Exclamation)

View File

@ -6,6 +6,7 @@ Imports Independentsoft.Email.Imap
Imports DigitalData.Modules.Logging
Imports System.Net.Mail
Imports System.Net
Imports System.Security
Public Class Email
Private _logger As Logging.Logger
@ -133,7 +134,6 @@ Public Class Email
mailfrom As String, mailsmtp As String, mailport As Integer, mailUser As String, mailPW As String,
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()
If mailto.Contains(";") Then
oReceipiants = mailto.Split(";")
@ -141,42 +141,42 @@ Public Class Email
ReDim Preserve oReceipiants(0)
oReceipiants(0) = mailto
End If
_logger.Debug($"mailsmtp [{mailsmtp}]")
_logger.Debug($"mailfrom [{mailfrom}]")
_logger.Debug($"mailport [{mailport}]")
For Each oMailReceipiant As String In oReceipiants
_logger.Debug($"oMailReceipiant [{oMailReceipiant}]")
_logger.Debug($"mailsmtp [{mailsmtp}]")
Dim sClient As Net.Mail.SmtpClient
Try
sClient = New Net.Mail.SmtpClient(mailsmtp, mailport)
Catch ex As Exception
_logger.Warn($"Could not create SMTP-Client: [{ex.Message}]")
Return False
End Try
sClient.DeliveryMethod = SmtpDeliveryMethod.Network
Dim mymesssage As New MailMessage
sClient.Port = mailport
_logger.Debug($"mailport [{mailport}]")
Dim oSmtp_Server As New Mail.SmtpClient
Dim oE_mail As New MailMessage()
oSmtp_Server.UseDefaultCredentials = False
oSmtp_Server.Credentials = New Net.NetworkCredential(mailUser, mailPW)
oSmtp_Server.Port = mailport
If AUTH_TYPE = "SSL" Then
_logger.Debug("SSL = true")
sClient.EnableSsl = True
oSmtp_Server.EnableSsl = True
Else
_logger.Debug("SSL = false")
sClient.EnableSsl = False
oSmtp_Server.EnableSsl = False
End If
_logger.Debug($"mailUser [{mailUser}]")
sClient.Credentials = New NetworkCredential(mailUser, mailPW)
sClient.UseDefaultCredentials = False
oSmtp_Server.Host = mailsmtp
oE_mail = New MailMessage()
oE_mail.From = New MailAddress(mailfrom)
oE_mail.To.Add(oMailReceipiant)
oE_mail.Subject = mailSubject
oE_mail.IsBodyHtml = False
If Test = True Then
mymesssage.Body = $"This is the body (text will be replaced within profile)! <br> mailsmtp: {mailsmtp} <br> mailport: {mailport} <br> mailUser: {mailUser} <br> mailPW: XXXX <br> AUTH_TYPE: {AUTH_TYPE}"
oE_mail.Body = $"This is the body (text will be replaced within profile)! <br> mailsmtp: {mailsmtp} <br> mailport: {mailport} <br> mailUser: {mailUser} <br> mailPW: XXXX <br> AUTH_TYPE: {AUTH_TYPE}"
Else
mymesssage.Body = mailBody
oE_mail.Body = mailBody
End If
_logger.Debug($"mailBody [{mailBody}]")
'mymesssage.IsBodyHtml = True
Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(mymesssage.Body)
oE_mail.IsBodyHtml = True
Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(oE_mail.Body)
htmlView.ContentType = New System.Net.Mime.ContentType("text/html")
mymesssage.AlternateViews.Add(htmlView)
oE_mail.AlternateViews.Add(htmlView)
_logger.Debug($"attachmentString [{attachmentString}]")
If attachmentString <> "" Then
_logger.Info($"Attachment Path is: {attachmentString}")
@ -189,29 +189,20 @@ Public Class Email
'ElseIf attment.ToLower.EndsWith("docx") Then
' oAttachment.ContentType = New Independentsoft.Email.Mime.ContentType("application", "MS-word")
'End If
mymesssage.Attachments.Add(oAttachment)
oE_mail.Attachments.Add(oAttachment)
Else
_logger.Debug("No Attachment.")
End If
_logger.Debug($"mailfrom [{mailfrom}]")
mymesssage.From = New MailAddress(mailfrom)
_logger.Debug($"mailSubject [{mailSubject}]")
mymesssage.Subject = mailSubject
mymesssage.To.Add(New MailAddress(oMailReceipiant))
_logger.Debug($"Now Sending mail...")
sClient.Send(mymesssage)
oSmtp_Server.Send(oE_mail)
_logger.Debug($"Mail has been sent!")
_logger.Info("Message to " & oMailReceipiant & " has been send.")
Next
If oError = False Then
Return True
Else
Return False
End If
Catch ex As Exception
_logger.Error(ex)
Return True
Catch error_t As Exception
_logger.Error(error_t)
Return False
End Try

View File

@ -1171,23 +1171,6 @@ Public Class Windream2
End Try
Dim ExportFileIO = New WMOTOOLLib.WMFileIO ' CreateObject("WMOTOOLLib.WMFileIO") ' New WMOTOOLLib.WMFileIO
_logger.Debug("ExportFileIO created...")
' Stream Interface bereitstellen
'Try
' oWMObject.LockFor(WMObjectEditModeMoveReadOnly) 'WMObjectEditModeFileSystem)
'Catch ex As Exception
' If Not oWMObject.aLocked Then
' Try
' oWMObject.lock()
' Catch ex1 As Exception
' _logger.Warn($"{ex1.Message} Could not lock document - DocID: {DocId}")
' Return False
' End Try
' End If
' '_logger.(ex)
'End Try
Dim oWMStream = oWMObject.OpenStream("BinaryObject", 1)
'### VERSIONIERUNG ###
Dim version As Integer = 2
@ -1204,10 +1187,9 @@ Public Class Windream2
ExportFileIO.bstrOriginalFileName = tempFilename
'Das eigentliche kopieren
ExportFileIO.ExportOriginal(True)
' close the windream file stream
'close the windream file stream
oWMStream.Close()
_logger.Info($"WMFile DocID {DocId} has been exported to {tempFilename} ")
Return True
Catch ex As Exception
_logger.Error(ex)