diff --git a/SDL/Fakturierung/frmSendEmail.vb b/SDL/Fakturierung/frmSendEmail.vb index 78b59a48..f5f34557 100644 --- a/SDL/Fakturierung/frmSendEmail.vb +++ b/SDL/Fakturierung/frmSendEmail.vb @@ -224,7 +224,7 @@ Public Class frmSendEmail ' Setzt den Mail-Text Private Sub setMailText() - Dim abfNr As String = " Pos-Nr.: " & RECHNUNG.LKW_Kennzeichen & "/" & RECHNUNG.FilialenNr & "-" & RECHNUNG.AbfertigungsNr & "-" & RECHNUNG.SpeditionsbuchUnterNr + Dim abfNr As String = " Pos-Nr.: " & RECHNUNG.FilialenNr & "-" & RECHNUNG.AbfertigungsNr & " LKW: " & RECHNUNG.LKW_Kennzeichen txtSubject.Text = "Verzollungsunterlagen zu " & abfNr @@ -240,9 +240,9 @@ Public Class frmSendEmail If SR Then Try - If RechnungsNr > 1 OrElse vbYes = MsgBox("Möchten Sie das PDF als Mail-Anhang erstellen?", vbYesNoCancel) Then - VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.clearTMPPath("Zusammenfassung") + + VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.clearTMPPath("Zusammenfassung") Dim listPDFs As New List(Of String) Dim SonstAnlagen As New List(Of String) Dim lastAktuelle_RgNr As Integer = -1 @@ -254,11 +254,8 @@ Public Class frmSendEmail Dim Mail_StbFA As Microsoft.Office.Interop.Outlook.MailItem = outl.CreateItem(0) Mail_StbFA.Subject = txtSubject.Text - If Firma_ID = 24 Then - Mail_StbFA.SentOnBehalfOfName = SDL.cFakturierung.getDefaultMail("AMBAR", , True) - End If - Dim Mail As Microsoft.Office.Interop.Outlook.MailItem = outl.CreateItem(0) + Dim Mail As Microsoft.Office.Interop.Outlook.MailItem = outl.CreateItem(0) Mail.Subject = txtSubject.Text If Firma_ID = 24 Then @@ -319,7 +316,7 @@ Public Class frmSendEmail Next End If Next - End If + If SPEDBUCH.DokumentId_Steuerbeleg IsNot Nothing Then ATTACHMENTS.Add(New cFakt_SendMailATTach(VERAG_PROG_ALLGEMEIN.cDATENSERVER.GET_PDFPath_BY_DocID(SPEDBUCH.DokumentId_Steuerbeleg), "Steuerbescheid.pdf")) @@ -336,69 +333,67 @@ Public Class frmSendEmail additionalLine = "Abrechnungsstelle: " & RECHNUNG.FakturierungsGruppe.Replace("WAI", "Waidhaus") End If - If RECHNUNG.Status <> 0 OrElse vbYes = MsgBox("Möchten Sie das PDF als Mail-Anhang erstellen?", vbYesNoCancel) Then - Try - Dim outl As New Outlook.Application - Dim Mail As Microsoft.Office.Interop.Outlook.MailItem = outl.CreateItem(0) - Dim RechnungsNrisSet As Boolean = False + Try + Dim outl As New Outlook.Application + Dim Mail As Microsoft.Office.Interop.Outlook.MailItem = outl.CreateItem(0) + Dim RechnungsNrisSet As Boolean = False - If Firma_ID = 24 Then - Try - Dim accountToSent As String = SDL.cFakturierung.getDefaultMail("AMBAR", , True) - For Each oAccount As Outlook.Account In outl.Session.Accounts - If oAccount.SmtpAddress = accountToSent Then - Mail.SendUsingAccount = oAccount - Exit For - End If - Next - Catch ex As System.Exception - VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR("Fehler beim Ermitteln des Mail-Accounts." & ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) - End Try + If Firma_ID = 24 Then + Try + Dim accountToSent As String = SDL.cFakturierung.getDefaultMail("AMBAR", , True) + For Each oAccount As Outlook.Account In outl.Session.Accounts + If oAccount.SmtpAddress = accountToSent Then + Mail.SendUsingAccount = oAccount + Exit For + End If + Next + Catch ex As System.Exception + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR("Fehler beim Ermitteln des Mail-Accounts." & ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + End Try + End If + + For Each r As DataGridViewRow In dgvEmail.Rows + If r.Cells(0).Value IsNot Nothing AndAlso r.Cells(0).Value.ToString() <> "" Then + Mail.To &= r.Cells(0).Value.ToString() & ";" End If + Next - For Each r As DataGridViewRow In dgvEmail.Rows - If r.Cells(0).Value IsNot Nothing AndAlso r.Cells(0).Value.ToString() <> "" Then - Mail.To &= r.Cells(0).Value.ToString() & ";" - End If - Next - - For Each r As DataGridViewRow In dgvEmailCC.Rows - If r.Cells(0).Value IsNot Nothing AndAlso r.Cells(0).Value.ToString() <> "" Then - Mail.CC &= r.Cells(0).Value.ToString() & ";" - End If - Next - - For Each r As DataGridViewRow In dgvEmailBCC.Rows - If r.Cells(0).Value IsNot Nothing AndAlso r.Cells(0).Value.ToString() <> "" Then - Mail.BCC &= r.Cells(0).Value.ToString() & ";" - End If - Next - - - Dim TextHTML As String = "