You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
209 lines
7.4 KiB
209 lines
7.4 KiB
Imports System.Net.Mail
|
|
Imports System.Web.Configuration
|
|
Imports System.Net
|
|
Public Class clsSendMail
|
|
|
|
Public Shared Sub SendMailMessage(ByVal from As String, ByVal recepient As String, ByVal bcc As String, ByVal cc As String, ByVal subject As String, ByVal body As String)
|
|
|
|
Dim ConfigFrom As String = "msscript1.shub.ch"
|
|
Dim mMailMessage As New MailMessage()
|
|
mMailMessage.From = New MailAddress("hutter@shub.ch")
|
|
mMailMessage.To.Add(New MailAddress("stefan.hutter@gewerbe-buelach.ch"))
|
|
mMailMessage.Subject = "stefan.hutter@gewerbe-buelach.ch"
|
|
mMailMessage.Body = "Test-Nachricht"
|
|
'Dim mSmtpClient As New SmtpClient()
|
|
|
|
' Dim msmtpclient As New SmtpClient("smtp.shub.ch", 587)
|
|
' msmtpclient.Credentials = New NetworkCredential("hutter@shub.ch", "shu*webland30")
|
|
'Dim msmtpclient As New SmtpClient("smtp.gmail.com", 587)
|
|
'msmtpclient.Credentials = New NetworkCredential("shutter29@gmail.com", "shu*google")
|
|
'msmtpclient.EnableSsl = True
|
|
'msmtpclient.Send(mMailMessage)
|
|
|
|
Dim msmtpclient As New SmtpClient("smtp.gmail.com", 578)
|
|
msmtpclient.Credentials = New NetworkCredential("shutter29@gmail.com", "shu*google")
|
|
msmtpclient.EnableSsl = True
|
|
msmtpclient.Send(mMailMessage)
|
|
'mSmtpClient.Send(mMailMessage)
|
|
End Sub
|
|
|
|
|
|
'Public Shared Sub SendMailMessage(ByVal from As String, ByVal recepient As String, ByVal bcc As String, ByVal cc As String, ByVal subject As String, ByVal body As String)
|
|
' Dim ConfigFrom As String
|
|
' ConfigFrom = WebConfigurationManager.AppSettings("MailAbsender")
|
|
' ' Instantiate a new instance of MailMessage
|
|
' Dim mMailMessage As New MailMessage()
|
|
|
|
' ' Set the sender address of the mail message
|
|
' If from = "" Then
|
|
' mMailMessage.From = New MailAddress(ConfigFrom)
|
|
' Else
|
|
' mMailMessage.From = New MailAddress(from)
|
|
' End If
|
|
' ' Set the recepient address of the mail message
|
|
' mMailMessage.To.Add(New MailAddress(recepient))
|
|
|
|
' ' Check if the bcc value is nothing or an empty string
|
|
' If Not bcc Is Nothing And bcc <> String.Empty Then
|
|
' ' Set the Bcc address of the mail message
|
|
' mMailMessage.Bcc.Add(New MailAddress(bcc))
|
|
' End If
|
|
|
|
' ' Check if the cc value is nothing or an empty value
|
|
' If Not cc Is Nothing And cc <> String.Empty Then
|
|
' ' Set the CC address of the mail message
|
|
' mMailMessage.CC.Add(New MailAddress(cc))
|
|
' End If
|
|
|
|
' ' Set the subject of the mail message
|
|
' mMailMessage.Subject = subject
|
|
' ' Set the body of the mail message
|
|
' mMailMessage.Body = body
|
|
|
|
' ' Set the format of the mail message body as HTML
|
|
' mMailMessage.IsBodyHtml = True
|
|
' ' Set the priority of the mail message to normal
|
|
' mMailMessage.Priority = MailPriority.Normal
|
|
|
|
' ' Instantiate a new instance of SmtpClient
|
|
' Dim mSmtpClient As New SmtpClient("msscript1.webland.ch")
|
|
' mSmtpClient.Send("Hutter@shub.ch", "info@shub.ch", "Test", "Test")
|
|
' ' mSmtpClient.Credentials = New NetworkCredential("hutter@shub.ch", "shu*webland30")
|
|
' ' mSmtpClient.Send(mMailMessage)
|
|
|
|
' '' Send the mail message
|
|
'End Sub
|
|
|
|
|
|
Public Shared Sub Send()
|
|
|
|
|
|
Const ToAddress As String = "info@shub.ch"
|
|
|
|
'(1) Create the MailMessage instance
|
|
Dim mm As New MailMessage("stefan.hutter@stefan-hutter.ch", "info@shub.ch")
|
|
|
|
'(2) Assign the MailMessage's properties
|
|
mm.Subject = "Hallo"
|
|
mm.Body = "Ich bin ein Test"
|
|
mm.IsBodyHtml = False
|
|
|
|
'(3) Create the SmtpClient object
|
|
Dim smtp As New SmtpClient
|
|
|
|
'(4) Send the MailMessage (will use the Web.config settings)
|
|
smtp.Send(mm)
|
|
Exit Sub
|
|
|
|
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
'Imports System.Net.Mail
|
|
'Imports System.Web.Configuration
|
|
'Imports System.Net
|
|
'Public Class clsSendMail
|
|
|
|
|
|
' Public Shared Sub SendMailMessage(ByVal from As String, ByVal recepient As String, ByVal bcc As String, ByVal cc As String, ByVal subject As String, ByVal body As String)
|
|
' Dim ConfigFrom As String
|
|
' ConfigFrom = WebConfigurationManager.AppSettings("MailAbsender")
|
|
|
|
' ' Instantiate a new instance of MailMessage
|
|
' Dim mMailMessage As New MailMessage()
|
|
|
|
|
|
|
|
' ' Set the sender address of the mail message
|
|
' If from = "" Then
|
|
' mMailMessage.From = New MailAddress(ConfigFrom)
|
|
' Else
|
|
' mMailMessage.From = New MailAddress(from)
|
|
' End If
|
|
' ' Set the recepient address of the mail message
|
|
' mMailMessage.To.Add(New MailAddress(recepient))
|
|
|
|
' ' Check if the bcc value is nothing or an empty string
|
|
' If Not bcc Is Nothing And bcc <> String.Empty Then
|
|
' ' Set the Bcc address of the mail message
|
|
' mMailMessage.Bcc.Add(New MailAddress(bcc))
|
|
' End If
|
|
|
|
' ' Check if the cc value is nothing or an empty value
|
|
' If Not cc Is Nothing And cc <> String.Empty Then
|
|
' ' Set the CC address of the mail message
|
|
' mMailMessage.CC.Add(New MailAddress(cc))
|
|
' End If
|
|
|
|
' ' Set the subject of the mail message
|
|
' mMailMessage.Subject = subject
|
|
' ' Set the body of the mail message
|
|
' mMailMessage.Body = body
|
|
|
|
' ' Set the format of the mail message body as HTML
|
|
' mMailMessage.IsBodyHtml = True
|
|
' ' Set the priority of the mail message to normal
|
|
' mMailMessage.Priority = MailPriority.Normal
|
|
|
|
' ' Instantiate a new instance of SmtpClient
|
|
' mMailMessage.From = New MailAddress("hutter@shub.ch")
|
|
' Dim mSmtpClient As New SmtpClient()
|
|
' ' Send the mail message
|
|
' mSmtpClient.Send(mMailMessage)
|
|
' Exit Sub
|
|
|
|
' ' Instantiate a new instance of SmtpClient
|
|
' 'Dim mSmtpClient As New SmtpClient()
|
|
' 'mMailMessage.From = New MailAddress("info@shub.ch")
|
|
' 'SendSmtp(mMailMessage)
|
|
' 'Exit Sub
|
|
' 'Dim mSmtpClient As New SmtpClient
|
|
' 'mSmtpClient.Host = "smtp.shub.ch"
|
|
|
|
' 'mSmtpClient.Port = 557
|
|
' 'mSmtpClient.EnableSsl = True
|
|
' 'mSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network
|
|
' 'mSmtpClient.UseDefaultCredentials = False
|
|
' 'mSmtpClient.Credentials = New NetworkCredential("hutter@shub.ch", "shu*webland30")
|
|
' '' Send the mail message
|
|
' 'mSmtpClient.Send(mMailMessage)
|
|
' End Sub
|
|
|
|
|
|
' Public Shared Sub Send()
|
|
|
|
|
|
' Const ToAddress As String = "info@shub.ch"
|
|
|
|
' '(1) Create the MailMessage instance
|
|
' Dim mm As New MailMessage("stefan.hutter@stefan-hutter.ch", "info@shub.ch")
|
|
|
|
' '(2) Assign the MailMessage's properties
|
|
' mm.Subject = "Hallo"
|
|
' mm.Body = "Ich bin ein Test"
|
|
' mm.IsBodyHtml = False
|
|
|
|
' '(3) Create the SmtpClient object
|
|
' Dim smtp As New SmtpClient
|
|
|
|
' '(4) Send the MailMessage (will use the Web.config settings)
|
|
' smtp.Send(mm)
|
|
' Exit Sub
|
|
' End Sub
|
|
|
|
' Public Shared Sub SendSmtp(ByVal m As MailMessage)
|
|
|
|
' Dim smtp As New SmtpClient
|
|
' smtp.Host = "smtp.p-hutter.ch"
|
|
' smtp.Port = 557
|
|
' smtp.EnableSsl = True
|
|
' smtp.DeliveryMethod = SmtpDeliveryMethod.Network
|
|
' smtp.UseDefaultCredentials = False
|
|
' smtp.Credentials = New NetworkCredential("drhutter@p-hutter.ch", "phu*phut29")
|
|
' smtp.Send(m)
|
|
|
|
' End Sub
|
|
|
|
'End Class
|