$smtpServer = "smtpServer"
$smtpUser = "smtpUser"
$smtpPassword = "smtpPassword "
$mail = New-Object System.Net.Mail.MailMessage
$MailAddress="MailAddress"
$MailtoAddress="MailtoAddress"
$mail.From = New-Object System.Net.Mail.MailAddress($MailAddress)
$mail.To.Add($MailtoAddress)
$mail.Subject = "Hello PowerShell";
$mail.Priority = "High"
$mail.Body = "Sending mail is easy!"
$filename="file"
$p_w_upload = new-Object System.Net.Mail.Attachment($filename)
$mail.Attachments.Add($p_w_upload)
$smtp = New-Object System.Net.Mail.SmtpClient -argumentList $smtpServer
$smtp.Credentials = New-Object System.Net.NetworkCredential -argumentList $smtpUser,$smtpPassword
$smtp.Send($mail)
$objMessage.From = "`"Krzysztof Pietrzak`" <[email]pkrzysz@nospam.pjwstk.edu.pl[/email]>"
$objMessage.To = "[email]pkrzysz@nospam.pjwstk.edu.pl[/email]"
$objMessage.Subject = " Message Subject"
$objMessage.TextBody = "Body of message"
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
#SMTP Server
$objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.server.org"
#SMTP Server Port
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
#Authenticaztion 1-Baasic, 2-NTLM
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 2
#Use ssl
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 0
#Timeout
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
$objMessage.Configuration.Fields.Update()
$objMessage.Send()
$objMessage.From = "`"Krzysztof Pietrzak`" <[email]pkrzysz@nospam.pjwstk.edu.pl[/email]>"
$objMessage.To = "[email]pkrzysz@nospam.pjwstk.edu.pl[/email]"
$objMessage.Subject = " Message Subject"
$objMessage.TextBody = "Body of message"
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
#SMTP Server
$objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "dfs2"
#SMTP Server Port
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
#Authenticaztion 1-Baasic, 2-NTLM
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
#UserID
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "yourUser"
#Password
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"
#Use ssl
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
#Timeout
$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
$objMessage.Configuration.Fields.Update()
$objMessage.Send()
objMessage.Subject = "Example CDO Message"
objMessage.From = "[email]me@my.com[/email]"
objMessage.To = "[email]test@paulsadowski.com[/email]"
objMessage.TextBody = "This is some sample message text."
objMessage.Send
objMessage.HTMLBody = "<h1>This is some sample message html.</h1>"
'The line below shows how to send a webpage from a remote site
objMessage.CreateMHTMLBody "http://www.paulsadowski.com/wsh/"
'The line below shows how to send a webpage from a file on your machine
objMessage.CreateMHTMLBody "file://c|/temp/test.htm"
objMessage.Bcc = "[email]you@your.com[/email]"
objMessage.Cc = “[email]you2@your.com[/email]”
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
objMessage.Subject = "Temat"
objMessage.From = """nadawca"" [email]nadawca@domena.com[/email]"
objMessage.To = "[email]odbiorca1@domena1.com[/email]"
objMessage.TextBody = "Serwer "
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpServer"
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoNTLM
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update
objMessage.Send
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = """Me"" <[email]me@my.com[/email]>"
objMessage.To = "[email]test@paulsadowski.com[/email]"
objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication."
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.your.com"
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "youruserid"
'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = TRUE
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
Set objNetwork = WScript.CreateObject("WScript.Network")
Set objMessage = CreateObject("CDONTS.NewMail")
set fs = CreateObject("Scripting.FileSystemObject")
set drive = fs.GetDrive("C:\")
strComputer = objNetwork.ComputerName
objMessage.Subject = "Daily report of C drive available space on " & strComputer
objMessage.From = "[email]icil_sup@icil.net[/email]"
objMessage.To = "[email]allenzhang@icil.net[/email],[email]havingchan@icil.net[/email]"
strSpace = "Available Space on C:\:" & FormatNumber(drive.AvailableSpace/1024^2) & "MB"
objMessage.Body = Now & vbtab & strComputer & vbtab & strSpace
objMessage.Send