Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports Microsoft.VisualBasic
- Imports System.Net.Mail
- Public Class clEmail
- Private clXML As New clXML
- Public strPath As String = IO.Path.GetDirectoryName(Reflection.Assembly.GetExecutingAssembly.Location) & "\"
- Private strAbsenderAdresse As String = clXML.ReadXMLValue(strPath & "cnf.xml", "EmailSender")
- Private strMailServer As String = clXML.ReadXMLValue(strPath & "cnf.xml", "EmailServer")
- Private strMailPort As String = clXML.ReadXMLValue(strPath & "cnf.xml", "EmailPort")
- Private strMailBenutzer As String = clXML.ReadXMLValue(strPath & "cnf.xml", "EmailUser")
- Private strMailPasswort As String = clXML.ReadXMLValue(strPath & "cnf.xml", "EmailPass")
- 'Mailversand
- 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
- Try
- Dim scSMTPClient As New SmtpClient(strMailServer, strMailPort)
- Dim ncNetWorkCredential As New Net.NetworkCredential(strMailBenutzer, strMailPasswort)
- scSMTPClient.Credentials = ncNetWorkCredential
- Dim mmMail As New MailMessage
- Dim mmAdressFrom As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
- Dim mmAdressReplyTo As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
- mmMail.From = mmAdressFrom
- mmMail.To.Add(strEmpfaenger)
- If strCC <> "" Then mmMail.CC.Add(strCC.Replace(";", ","))
- If strBCC <> "" Then mmMail.Bcc.Add(strBCC.Replace(";", ","))
- mmMail.Subject = strBetreff
- mmMail.Body = strNachricht
- mmMail.Priority = intPriority
- mmMail.ReplyTo = mmAdressReplyTo
- mmMail.IsBodyHtml = True
- scSMTPClient.Send(mmMail)
- Return True
- Catch ex As Exception
- Return False
- End Try
- End Function
- 'Mailversand + 1 Att
- 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
- Try
- Dim scSMTPClient As New SmtpClient(strMailServer, strMailPort)
- Dim ncNetWorkCredential As New Net.NetworkCredential(strMailBenutzer, strMailPasswort)
- scSMTPClient.Credentials = ncNetWorkCredential
- Dim mmMail As New MailMessage
- Dim mmAdressFrom As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
- Dim mmAdressReplyTo As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
- mmMail.From = mmAdressFrom
- mmMail.To.Add(strEmpfaenger)
- If strCC <> "" Then mmMail.CC.Add(strCC.Replace(";", ","))
- If strBCC <> "" Then mmMail.Bcc.Add(strBCC.Replace(";", ","))
- mmMail.Subject = strBetreff
- mmMail.Body = strNachricht
- If Not strAtt1Path = "" Then
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt1Path))
- End If
- mmMail.Priority = intPriority
- mmMail.ReplyTo = mmAdressReplyTo
- mmMail.IsBodyHtml = True
- scSMTPClient.EnableSsl = True
- scSMTPClient.Send(mmMail)
- Return True
- Catch ex As Exception
- MsgBox(ex.Message)
- Return False
- End Try
- End Function
- 'Mailversand + 2 Att
- 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
- Try
- Dim scSMTPClient As New SmtpClient(strMailServer, strMailPort)
- Dim ncNetWorkCredential As New Net.NetworkCredential(strMailBenutzer, strMailPasswort)
- scSMTPClient.Credentials = ncNetWorkCredential
- Dim mmMail As New MailMessage
- Dim mmAdressFrom As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
- Dim mmAdressReplyTo As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
- mmMail.From = mmAdressFrom
- mmMail.To.Add(strEmpfaenger)
- If strCC <> "" Then mmMail.CC.Add(strCC.Replace(";", ","))
- If strBCC <> "" Then mmMail.Bcc.Add(strBCC.Replace(";", ","))
- mmMail.Subject = strBetreff
- mmMail.Body = strNachricht
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt1Path))
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt2Path))
- mmMail.Priority = intPriority
- mmMail.ReplyTo = mmAdressReplyTo
- mmMail.IsBodyHtml = True
- scSMTPClient.Send(mmMail)
- Return True
- Catch ex As Exception
- Return False
- End Try
- End Function
- 'Mailversand + 3 Att
- 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
- Try
- Dim scSMTPClient As New SmtpClient(strMailServer, strMailPort)
- Dim ncNetWorkCredential As New Net.NetworkCredential(strMailBenutzer, strMailPasswort)
- scSMTPClient.Credentials = ncNetWorkCredential
- Dim mmMail As New MailMessage
- Dim mmAdressFrom As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
- Dim mmAdressReplyTo As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
- mmMail.From = mmAdressFrom
- mmMail.To.Add(strEmpfaenger)
- If strCC <> "" Then mmMail.CC.Add(strCC.Replace(";", ","))
- If strBCC <> "" Then mmMail.Bcc.Add(strBCC.Replace(";", ","))
- mmMail.Subject = strBetreff
- mmMail.Body = strNachricht
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt1Path))
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt2Path))
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt3Path))
- mmMail.Priority = intPriority
- mmMail.ReplyTo = mmAdressReplyTo
- mmMail.IsBodyHtml = True
- scSMTPClient.Send(mmMail)
- Return True
- Catch ex As Exception
- Return False
- End Try
- End Function
- 'Mailversand + 4 Att
- 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
- Try
- Dim scSMTPClient As New SmtpClient(strMailServer, strMailPort)
- Dim ncNetWorkCredential As New Net.NetworkCredential(strMailBenutzer, strMailPasswort)
- scSMTPClient.Credentials = ncNetWorkCredential
- Dim mmMail As New MailMessage
- Dim mmAdressFrom As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
- Dim mmAdressReplyTo As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
- mmMail.From = mmAdressFrom
- mmMail.To.Add(strEmpfaenger)
- If strCC <> "" Then mmMail.CC.Add(strCC.Replace(";", ","))
- If strBCC <> "" Then mmMail.Bcc.Add(strBCC.Replace(";", ","))
- mmMail.Subject = strBetreff
- mmMail.Body = strNachricht
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt1Path))
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt2Path))
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt3Path))
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt4Path))
- mmMail.Priority = intPriority
- mmMail.ReplyTo = mmAdressReplyTo
- mmMail.IsBodyHtml = True
- scSMTPClient.Send(mmMail)
- Return True
- Catch ex As Exception
- Return False
- End Try
- End Function
- 'Mailversand + 5 Att
- 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
- Try
- Dim scSMTPClient As New SmtpClient(strMailServer, strMailPort)
- Dim ncNetWorkCredential As New Net.NetworkCredential(strMailBenutzer, strMailPasswort)
- scSMTPClient.Credentials = ncNetWorkCredential
- Dim mmMail As New MailMessage
- Dim mmAdressFrom As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
- Dim mmAdressReplyTo As New MailAddress(strAbsenderAdresse, strAbsenderAnzeige)
- mmMail.From = mmAdressFrom
- mmMail.To.Add(strEmpfaenger)
- If strCC <> "" Then mmMail.CC.Add(strCC.Replace(";", ","))
- If strBCC <> "" Then mmMail.Bcc.Add(strBCC.Replace(";", ","))
- mmMail.Subject = strBetreff
- mmMail.Body = strNachricht
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt1Path))
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt2Path))
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt3Path))
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt4Path))
- mmMail.Attachments.Add(New System.Net.Mail.Attachment(strAtt5Path))
- mmMail.Priority = intPriority
- mmMail.ReplyTo = mmAdressReplyTo
- mmMail.IsBodyHtml = True
- scSMTPClient.Send(mmMail)
- Return True
- Catch ex As Exception
- Return False
- End Try
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement