mutt -s $subject -c $ccpt_list -a $attachfile $rcpt_list < $email
Const SMTP_SERVER = "SMTP mail server address"---
Const SMTP_PORT = 25
Set objMessage = CreateObject("CDO.Message")
objMessage.Sender = sSender 'Email address of sender
objMessage.To = sRecipients 'Comma separate list of people who will receive the email
objMessage.Subject = sSubject 'The subject of the email
objMessage.Textbody = sBody 'The body of the email.
'This is optional. sAttachment is the fully qualified path to the file to attach
objMessage.AddAttachment sAttachment
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTP_SERVER
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTP_PORT
objMessage.Configuration.Fields.Update
objMessage.send
function send-email($s,$b,$to) {
$from = "send@company.com"; //Who will be sending the email
$domain = "smtp.company.com"; //SMTP server to send the message
$mail = new-object System.Net.Mail.MailMessage;
for($i=0; $i -lt $to.Length; $i++) {
$mail.To.Add($to[$i]);
}
$mail.From = new-object System.Net.Mail.MailAddress($from);
$mail.Subject = $s;
$mail.Body = $b;
$smtp = new-object System.Net.Mail.SmtpClient($domain);
$smtp.Send($mail);
}
$SUBJECT="This is the subject";Sending email is pretty easy and I know that there are a lot of places on the Web that already so you how to send email. Hopefully, though we can build off this to build much more complex scripts. I received an email from VMware concerning their Powershell interface to ESX. I am planning on next week to show how to write some simple scripts to manage an ESX build out with Powershell and we'll be using the send-email functions.
$EMAILADDR=@("person1@company.com","person2@company.com");
$BODY="Hello World";
send-email -s $SUBJECT -b $BODY -to $EMAILADDR
Labels: email, linux, powershell, vbscript, windows
October 2007 November 2007 December 2007 January 2008 February 2008 April 2008 October 2009 November 2009
Subscribe to Posts [Atom]