mirror of
https://gitlab.com/harald.mueller/aktuelle.kurse.git
synced 2024-11-27 20:21:56 +01:00
muh
This commit is contained in:
parent
eb9625adbd
commit
25ec5ea57c
BIN
m122/tools-technics/mailing-mit-powershell1/MailPW.txt
Normal file
BIN
m122/tools-technics/mailing-mit-powershell1/MailPW.txt
Normal file
Binary file not shown.
BIN
m122/tools-technics/mailing-mit-powershell1/data.pdf
Normal file
BIN
m122/tools-technics/mailing-mit-powershell1/data.pdf
Normal file
Binary file not shown.
BIN
m122/tools-technics/mailing-mit-powershell1/powershell-mails.zip
Normal file
BIN
m122/tools-technics/mailing-mit-powershell1/powershell-mails.zip
Normal file
Binary file not shown.
@ -0,0 +1,35 @@
|
|||||||
|
|
||||||
|
# Method to write an email with the logfile as attachement
|
||||||
|
#--------------------------------------------------------------------------------------------------
|
||||||
|
function sendmail() {
|
||||||
|
$toMail = "harald.mueller@bluewin.ch"
|
||||||
|
$attachment = "C:\Users\Harald\OneDrive\Technik\mails\data.pdf"
|
||||||
|
|
||||||
|
$SMTPServer = "smtp.gmail.com"
|
||||||
|
$SMTPPort = "587"
|
||||||
|
$Username = "invoice.autointerleasing@gmail.com"
|
||||||
|
|
||||||
|
# password of the mail account
|
||||||
|
$Password = "invoice77autointerleasing" | ConvertTo-SecureString -AsPlainText -Force
|
||||||
|
|
||||||
|
$subject = "Powi mail"
|
||||||
|
$body = "Logfile has been modified. Please review attached document $entry."
|
||||||
|
|
||||||
|
$message = New-Object System.Net.Mail.MailMessage
|
||||||
|
$message.subject = $subject
|
||||||
|
$message.body = $body
|
||||||
|
$message.to.add($toMail)
|
||||||
|
$message.from = $username
|
||||||
|
$message.attachments.add($attachment)
|
||||||
|
|
||||||
|
$smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
|
||||||
|
$smtp.EnableSSL = $true
|
||||||
|
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
|
||||||
|
$smtp.send($message)
|
||||||
|
}
|
||||||
|
## (Get-Credential).password | ConvertFrom-SecureString > mailpasswort.txt
|
||||||
|
## $pw = Get-Content .\mailpasswort.txt | ConvertTo-SecureString
|
||||||
|
## $cred = New-Object System.Management.Automation.PSCredential "MailUser", $pw
|
||||||
|
## Send-MailMessage -Credential $cred -to "harald.mueller@bluewin.ch" -from "PowerShell <ps@fabrikam.de>" -Subject "Test" -body "Test für Send-MailMessage"
|
||||||
|
|
||||||
|
sendmail
|
@ -0,0 +1,83 @@
|
|||||||
|
## (Get-Credential).password | ConvertFrom-SecureString > mailpasswort.txt
|
||||||
|
## $pw = Get-Content .\mailpasswort.txt | ConvertTo-SecureString
|
||||||
|
## $cred = New-Object System.Management.Automation.PSCredential "MailUser", $pw
|
||||||
|
## Send-MailMessage -Credential $cred -to "harald.mueller@bluewin.ch" -from "PowerShell <ps@fabrikam.de>" -Subject "Test" -body "Test für Send-MailMessage"
|
||||||
|
|
||||||
|
$body =
|
||||||
|
"IHRE RECHNUNG VON AUTO-INTERLEASING AG
|
||||||
|
VOTRE FACTURE D'AUTO-INTERLEASING SA
|
||||||
|
|
||||||
|
Sehr geehrte Damen und Herren
|
||||||
|
Madame, Monsieur,
|
||||||
|
|
||||||
|
Mit dieser Mail erhalten Sie die aktuelle Rechnung von Auto-Interleasing als PDF. Die Papierrechnung erhalten Sie wie gewohnt mit der Post.
|
||||||
|
Par ce présent courrier, nous vous transmettons la facture d'Auto-Interleasing en version PDF. La facture papier vous parviendra comme d'habitude par courrier postal.
|
||||||
|
|
||||||
|
Wir bitten Sie, den offenen Betrag unter Einhaltung der Zahlungsfrist an die auf dem beigefügten Einzahlungsschein vermerkten Kontonummer zu überweisen.
|
||||||
|
Nous vous prions de verser le montant dû conformément au délai de paiement mentionné sur le bulletin de versement joint.
|
||||||
|
|
||||||
|
Einzahlung für:
|
||||||
|
Versement pour:
|
||||||
|
|
||||||
|
Auto-Interleasing AG
|
||||||
|
St. Jakob-Strasse 72
|
||||||
|
4132 Muttenz
|
||||||
|
|
||||||
|
IBAN: CH21 0023 3233 1012 5122 0
|
||||||
|
|
||||||
|
|
||||||
|
Freundliche Grüsse,
|
||||||
|
Avec nos cordiales salutations,
|
||||||
|
|
||||||
|
Auto-Interleasing AG
|
||||||
|
St. Jakob-Strasse 72
|
||||||
|
4132 Muttenz
|
||||||
|
+41 61 319 32 32
|
||||||
|
info@auto-interleasing.ch
|
||||||
|
www.auto-interleasing.ch
|
||||||
|
|
||||||
|
|
||||||
|
Für die elektronische Rechnung sind Sie mit obiger E-Mail-Adresse bei uns registriert.
|
||||||
|
Pour l'envoi des factures par voie électronique, vous êtes inscrits avec l'adresse e-mail mentionnée ci-dessus
|
||||||
|
|
||||||
|
Allfällige Änderungen Ihrer E-Mail-Adresse teilen Sie bitte unverzüglich Ihrem Kundenbetreuer mit.
|
||||||
|
Pour toute modification de votre adresse e-mail, nous vous prions de contacter votre gestionnaire.
|
||||||
|
|
||||||
|
Bitte beachten Sie, dass Antworten auf diese E-Mail-Adresse leider nicht beantwortet werden können.
|
||||||
|
Im Falle von Rückfragen oder Unklarheiten wenden Sie sich bitte an Ihren zuständigen Kundenbetreuer.
|
||||||
|
|
||||||
|
Vielen Dank!
|
||||||
|
|
||||||
|
Veuillez prendre note qu'aucune correspondance ne peut être échangée par le biais de cette adresse e-mail.
|
||||||
|
Pour toutes questions ou informations, nous vous prions de contacter votre gestionnaire. Merci beaucoup !
|
||||||
|
"
|
||||||
|
$SMTPHost = "smtp.gmail.com"
|
||||||
|
$SMTPPort = "587"
|
||||||
|
$Username = "invoice.autointerleasing@gmail.com"
|
||||||
|
$Password = "invoice77autointerleasing" | ConvertTo-SecureString -AsPlainText -Force
|
||||||
|
|
||||||
|
$subjectFixtext = "RECHNUNG/FACTURE"
|
||||||
|
|
||||||
|
$smtp = New-Object System.Net.Mail.SmtpClient($SMTPHost, $SMTPPort);
|
||||||
|
$smtp.EnableSSL = $true
|
||||||
|
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
|
||||||
|
|
||||||
|
$message = New-Object System.Net.Mail.MailMessage
|
||||||
|
$message.from = $username
|
||||||
|
$message.body = $body
|
||||||
|
|
||||||
|
# Method to write an email with the logfile as attachement
|
||||||
|
function sendmail ([String] $toMail, [String] $attachment, [String] $RgNr) {
|
||||||
|
# $toMail = "harald.mueller@bluewin.ch"
|
||||||
|
# $attachment = "C:\Users\Harald\OneDrive\Technik\mails\data.pdf"
|
||||||
|
|
||||||
|
$message.to.add("$toMail")
|
||||||
|
$message.attachments.add("$attachment")
|
||||||
|
$message.subject = $subjectFixtext + " Nr. " + $RgNr
|
||||||
|
|
||||||
|
echo $toMail
|
||||||
|
echo $attachment
|
||||||
|
# $smtp.send($message)
|
||||||
|
}
|
||||||
|
|
||||||
|
sendmail ("harald.mueller@bluewin.ch", "C:\Users\Harald\OneDrive\Technik\mails\data.pdf", "1")
|
Binary file not shown.
Binary file not shown.
BIN
m122/tools-technics/mailing-mit-powershell2/mailBeilage1.pdf
Normal file
BIN
m122/tools-technics/mailing-mit-powershell2/mailBeilage1.pdf
Normal file
Binary file not shown.
BIN
m122/tools-technics/mailing-mit-powershell2/mailBeilage2.pdf
Normal file
BIN
m122/tools-technics/mailing-mit-powershell2/mailBeilage2.pdf
Normal file
Binary file not shown.
BIN
m122/tools-technics/mailing-mit-powershell2/mail_ps1.zip
Normal file
BIN
m122/tools-technics/mailing-mit-powershell2/mail_ps1.zip
Normal file
Binary file not shown.
48
m122/tools-technics/mailing-mit-powershell2/mail_via_tam.ps1
Normal file
48
m122/tools-technics/mailing-mit-powershell2/mail_via_tam.ps1
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# man kann auch eine Liste von Adresssaten angeben a@xy.com, b@xy.com
|
||||||
|
$to = "harald.mueller@bluewin.ch"
|
||||||
|
$cc = ""
|
||||||
|
$bcc = ""
|
||||||
|
|
||||||
|
$subject = "Email Subject"
|
||||||
|
$body = "Hallo "+$To.Split("@")[0]
|
||||||
|
$body += "`n"
|
||||||
|
$body += "`n`nSchön, dass das klappt mit dem Mail!"
|
||||||
|
$body += "`n"
|
||||||
|
$body += "`nMit freundlichen Grüssen"
|
||||||
|
$body += "`nHarald Müller"
|
||||||
|
|
||||||
|
|
||||||
|
$SMTPServer = "mta.tam.ch" # Mailserver der Berufsschulen des Kantons Zürich
|
||||||
|
$SMTPPort = "587" # SSL-Port ist 587, Normal-Port wäre 465, man müsste dann aber "$SMTP_objekt.EnableSSL = $false" setzen
|
||||||
|
# vorname.nachname@edu.tbz.ch
|
||||||
|
$Username = "harald.mueller@tbz.ch"
|
||||||
|
$Password = "" # Hier Passwort eingeben
|
||||||
|
|
||||||
|
|
||||||
|
$Message_Objekt = New-Object System.Net.Mail.MailMessage
|
||||||
|
$Message_Objekt.from = $username
|
||||||
|
$Message_Objekt.subject = $subject
|
||||||
|
$Message_Objekt.body = $body
|
||||||
|
$Message_Objekt.to.add($to)
|
||||||
|
if ($cc.Length -gt 5) { # falls ein cc angegeben wurde
|
||||||
|
$Message_Objekt.cc.add($cc)
|
||||||
|
}
|
||||||
|
if ($bcc.Length -gt 5) { # falls ein bcc angegeben wurde
|
||||||
|
$Message_Objekt.Bcc.add($bcc)
|
||||||
|
}
|
||||||
|
|
||||||
|
$Message_Objekt.Attachments.add("C:\Users\harald\OneDrive - TBZ\M122-AutomMitSkriptenPS\05_Konkrete_Aufgabenstellungen\auto-mailer\mailBeilage1.pdf")
|
||||||
|
|
||||||
|
# es würde auch folgendes gehen
|
||||||
|
#[array]$attachmentArr = @()
|
||||||
|
#$attachmentArr = "mailBeilage1.pdf", "mailBeilage2.pdf"
|
||||||
|
|
||||||
|
#foreach ($a in $attachmentArr) { # falls mehr als eine Datei angegeben wurde wird jedes addiert
|
||||||
|
# $Message_Objekt.Attachments.add($a)
|
||||||
|
#}
|
||||||
|
|
||||||
|
$SMTP_objekt = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
|
||||||
|
$SMTP_objekt.EnableSSL = $true # $False setzen, wenn man den Normal-Port nimmt
|
||||||
|
$SMTP_objekt.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
|
||||||
|
$SMTP_objekt.send($Message_Objekt)
|
||||||
|
write-host "Mail Sent"
|
BIN
m122/tools-technics/mailing-mit-powershell2/mail_via_tam.zip
Normal file
BIN
m122/tools-technics/mailing-mit-powershell2/mail_via_tam.zip
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user