Advertisement
Guest User

Untitled

a guest
Nov 30th, 2018
2,376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 10.35 KB | None | 0 0
  1. Imports Microsoft.VisualBasic
  2. Imports System.Net.Mail
  3.  
  4.  
  5. Public Class clEmail
  6.     Private clXML As New clXML
  7.  
  8.     Public strPath As String = IO.Path.GetDirectoryName(Reflection.Assembly.GetExecutingAssembly.Location) & "\"
  9.  
  10.     Private strAbsenderAdresse As String = clXML.ReadXMLValue(strPath & "cnf.xml", "EmailSender")      
  11.     Private strMailServer As String = clXML.ReadXMLValue(strPath & "cnf.xml", "EmailServer")          
  12.     Private strMailPort As String = clXML.ReadXMLValue(strPath & "cnf.xml", "EmailPort")            
  13.     Private strMailBenutzer As String = clXML.ReadXMLValue(strPath & "cnf.xml", "EmailUser")        
  14.     Private strMailPasswort As String = clXML.ReadXMLValue(strPath & "cnf.xml", "EmailPass")        
  15.  
  16.  
  17.     'Mailversand
  18.     Public Function Mail(ByVal strEmpfaenger As String, ByVal strBetreff As String, ByVal strNachricht As String, ByVal strCC As String, ByVal strBCC As String, ByVal intPriority As Integer, ByVal strAbsenderAnzeige As String) As Boolean
  19.         Try
  20.             Dim scSMTPClient As New SmtpClient(strMailServer, strMailPort)
  21.             Dim ncNetWorkCredential As New Net.NetworkCredential(strMailBenutzer, strMailPasswort)
  22.             scSMTPClient.Credentials = ncNetWorkCredential
  23.  
  24.             Dim mmMail As New MailMessage
  25.             Dim mmAdressFrom As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
  26.             Dim mmAdressReplyTo As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
  27.  
  28.             mmMail.From = mmAdressFrom
  29.             mmMail.To.Add(strEmpfaenger)
  30.             If strCC <> "" Then mmMail.CC.Add(strCC.Replace(";", ","))
  31.             If strBCC <> "" Then mmMail.Bcc.Add(strBCC.Replace(";", ","))
  32.             mmMail.Subject = strBetreff
  33.             mmMail.Body = strNachricht
  34.  
  35.             mmMail.Priority = intPriority
  36.             mmMail.ReplyTo = mmAdressReplyTo
  37.             mmMail.IsBodyHtml = True
  38.  
  39.             scSMTPClient.Send(mmMail)
  40.             Return True
  41.         Catch ex As Exception
  42.             Return False
  43.         End Try
  44.     End Function
  45.  
  46.     'Mailversand + 1 Att
  47.     Public Function Mail(ByVal strEmpfaenger As String, ByVal strBetreff As String, ByVal strNachricht As String, ByVal strCC As String, ByVal strBCC As String, ByVal intPriority As Integer, ByVal strAbsenderAnzeige As String, ByVal strAtt1Path As String) As Boolean
  48.         Try
  49.             Dim scSMTPClient As New SmtpClient(strMailServer, strMailPort)
  50.             Dim ncNetWorkCredential As New Net.NetworkCredential(strMailBenutzer, strMailPasswort)
  51.             scSMTPClient.Credentials = ncNetWorkCredential
  52.  
  53.             Dim mmMail As New MailMessage
  54.             Dim mmAdressFrom As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
  55.             Dim mmAdressReplyTo As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
  56.  
  57.             mmMail.From = mmAdressFrom
  58.             mmMail.To.Add(strEmpfaenger)
  59.             If strCC <> "" Then mmMail.CC.Add(strCC.Replace(";", ","))
  60.             If strBCC <> "" Then mmMail.Bcc.Add(strBCC.Replace(";", ","))
  61.             mmMail.Subject = strBetreff
  62.             mmMail.Body = strNachricht
  63.  
  64.             If Not strAtt1Path = "" Then
  65.                 mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt1Path))
  66.             End If
  67.  
  68.             mmMail.Priority = intPriority
  69.             mmMail.ReplyTo = mmAdressReplyTo
  70.             mmMail.IsBodyHtml = True
  71.  
  72.             scSMTPClient.EnableSsl = True
  73.             scSMTPClient.Send(mmMail)
  74.             Return True
  75.         Catch ex As Exception
  76.             MsgBox(ex.Message)
  77.             Return False
  78.         End Try
  79.     End Function
  80.  
  81.     'Mailversand + 2 Att
  82.     Public Function Mail(ByVal strEmpfaenger As String, ByVal strBetreff As String, ByVal strNachricht As String, ByVal strCC As String, ByVal strBCC As String, ByVal intPriority As Integer, ByVal strAbsenderAnzeige As String, ByVal strAtt1Path As String, ByVal strAtt2Path As String) As Boolean
  83.         Try
  84.             Dim scSMTPClient As New SmtpClient(strMailServer, strMailPort)
  85.             Dim ncNetWorkCredential As New Net.NetworkCredential(strMailBenutzer, strMailPasswort)
  86.             scSMTPClient.Credentials = ncNetWorkCredential
  87.  
  88.             Dim mmMail As New MailMessage
  89.             Dim mmAdressFrom As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
  90.             Dim mmAdressReplyTo As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
  91.  
  92.             mmMail.From = mmAdressFrom
  93.             mmMail.To.Add(strEmpfaenger)
  94.             If strCC <> "" Then mmMail.CC.Add(strCC.Replace(";", ","))
  95.             If strBCC <> "" Then mmMail.Bcc.Add(strBCC.Replace(";", ","))
  96.             mmMail.Subject = strBetreff
  97.             mmMail.Body = strNachricht
  98.  
  99.             mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt1Path))
  100.             mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt2Path))
  101.  
  102.             mmMail.Priority = intPriority
  103.             mmMail.ReplyTo = mmAdressReplyTo
  104.             mmMail.IsBodyHtml = True
  105.  
  106.             scSMTPClient.Send(mmMail)
  107.             Return True
  108.         Catch ex As Exception
  109.             Return False
  110.         End Try
  111.     End Function
  112.  
  113.     'Mailversand + 3 Att
  114.     Public Function Mail(ByVal strEmpfaenger As String, ByVal strBetreff As String, ByVal strNachricht As String, ByVal strCC As String, ByVal strBCC As String, ByVal intPriority As Integer, ByVal strAbsenderAnzeige As String, ByVal strAtt1Path As String, ByVal strAtt2Path As String, ByVal strAtt3Path As String) As Boolean
  115.         Try
  116.             Dim scSMTPClient As New SmtpClient(strMailServer, strMailPort)
  117.             Dim ncNetWorkCredential As New Net.NetworkCredential(strMailBenutzer, strMailPasswort)
  118.             scSMTPClient.Credentials = ncNetWorkCredential
  119.  
  120.             Dim mmMail As New MailMessage
  121.             Dim mmAdressFrom As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
  122.             Dim mmAdressReplyTo As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
  123.  
  124.             mmMail.From = mmAdressFrom
  125.             mmMail.To.Add(strEmpfaenger)
  126.             If strCC <> "" Then mmMail.CC.Add(strCC.Replace(";", ","))
  127.             If strBCC <> "" Then mmMail.Bcc.Add(strBCC.Replace(";", ","))
  128.             mmMail.Subject = strBetreff
  129.             mmMail.Body = strNachricht
  130.  
  131.             mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt1Path))
  132.             mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt2Path))
  133.             mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt3Path))
  134.  
  135.             mmMail.Priority = intPriority
  136.             mmMail.ReplyTo = mmAdressReplyTo
  137.             mmMail.IsBodyHtml = True
  138.  
  139.             scSMTPClient.Send(mmMail)
  140.             Return True
  141.         Catch ex As Exception
  142.             Return False
  143.         End Try
  144.     End Function
  145.  
  146.     'Mailversand + 4 Att
  147.     Public Function Mail(ByVal strEmpfaenger As String, ByVal strBetreff As String, ByVal strNachricht As String, ByVal strCC As String, ByVal strBCC As String, ByVal intPriority As Integer, ByVal strAbsenderAnzeige As String, ByVal strAtt1Path As String, ByVal strAtt2Path As String, ByVal strAtt3Path As String, ByVal strAtt4Path As String) As Boolean
  148.         Try
  149.             Dim scSMTPClient As New SmtpClient(strMailServer, strMailPort)
  150.             Dim ncNetWorkCredential As New Net.NetworkCredential(strMailBenutzer, strMailPasswort)
  151.             scSMTPClient.Credentials = ncNetWorkCredential
  152.  
  153.             Dim mmMail As New MailMessage
  154.             Dim mmAdressFrom As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
  155.             Dim mmAdressReplyTo As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
  156.  
  157.             mmMail.From = mmAdressFrom
  158.             mmMail.To.Add(strEmpfaenger)
  159.             If strCC <> "" Then mmMail.CC.Add(strCC.Replace(";", ","))
  160.             If strBCC <> "" Then mmMail.Bcc.Add(strBCC.Replace(";", ","))
  161.             mmMail.Subject = strBetreff
  162.             mmMail.Body = strNachricht
  163.  
  164.             mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt1Path))
  165.             mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt2Path))
  166.             mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt3Path))
  167.             mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt4Path))
  168.  
  169.             mmMail.Priority = intPriority
  170.             mmMail.ReplyTo = mmAdressReplyTo
  171.             mmMail.IsBodyHtml = True
  172.  
  173.             scSMTPClient.Send(mmMail)
  174.             Return True
  175.         Catch ex As Exception
  176.             Return False
  177.         End Try
  178.     End Function
  179.  
  180.     'Mailversand + 5 Att
  181.     Public Function Mail(ByVal strEmpfaenger As String, ByVal strBetreff As String, ByVal strNachricht As String, ByVal strCC As String, ByVal strBCC As String, ByVal intPriority As Integer, ByVal strAbsenderAnzeige As String, ByVal strAtt1Path As String, ByVal strAtt2Path As String, ByVal strAtt3Path As String, ByVal strAtt4Path As String, ByVal strAtt5Path As String) As Boolean
  182.         Try
  183.             Dim scSMTPClient As New SmtpClient(strMailServer, strMailPort)
  184.             Dim ncNetWorkCredential As New Net.NetworkCredential(strMailBenutzer, strMailPasswort)
  185.             scSMTPClient.Credentials = ncNetWorkCredential
  186.  
  187.             Dim mmMail As New MailMessage
  188.             Dim mmAdressFrom As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
  189.             Dim mmAdressReplyTo As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
  190.  
  191.             mmMail.From = mmAdressFrom
  192.             mmMail.To.Add(strEmpfaenger)
  193.             If strCC <> "" Then mmMail.CC.Add(strCC.Replace(";", ","))
  194.             If strBCC <> "" Then mmMail.Bcc.Add(strBCC.Replace(";", ","))
  195.             mmMail.Subject = strBetreff
  196.             mmMail.Body = strNachricht
  197.  
  198.             mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt1Path))
  199.             mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt2Path))
  200.             mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt3Path))
  201.             mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt4Path))
  202.             mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt5Path))
  203.  
  204.             mmMail.Priority = intPriority
  205.             mmMail.ReplyTo = mmAdressReplyTo
  206.             mmMail.IsBodyHtml = True
  207.  
  208.             scSMTPClient.Send(mmMail)
  209.             Return True
  210.         Catch ex As Exception
  211.             Return False
  212.         End Try
  213.     End Function
  214.  
  215. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement