Powershell for Sending Attachment and Multiple Recipent

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Powershell for Sending Attachment and Multiple Recipent
# 1  
Old 05-24-2018
Powershell for Sending Attachment and Multiple Recipent

Hi there,

How could I invoke powershell to:
1. Send a file or an attachment
2. Send a content to multiple recipient
3. Be invoked by a batch file to execute the param clause

Help will be appreciate.


Code:
param(
	[string]$highs, [string]$mediums, [string]$lows 
)

$EmailFrom = “name@domain.com”
$EmailTo = “xxxxx@XXX.com”
$Subject = “New Scan is done!”
$Body = "High=$highs, Mediums=$mediums, Lows=$lows"
$SMTPServer = “smtp.gmail.com”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("Google-UserName", “Google-Password”);
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need help sending attachment via mailx

Hello, I am new to the Unix thing, and I am having trouble sending attachments via shell client putty through mailx. The command I use is $ mailx -s "Subject" user@blah.com < attachment.txt but everytime I do that it would say Cannot open attachment.txt I have the file save to my computer... (5 Replies)
Discussion started by: mrobin20
5 Replies

2. Shell Programming and Scripting

Need help in sending html mail with attachment

Hi Everyone, I am facing problems in sending html mail with attachemnt. I will able to send mail with attachment (plain text ) using mailx -s and uuencode command and also html mail without attachment using sendmail option. However I am not able to send html mail along with attachment.Either... (2 Replies)
Discussion started by: karthik adiga
2 Replies

3. Shell Programming and Scripting

Sending attachment using sendmail command

Send_Mail() { C_Date=`date +"%m/%d/%Y"` #Subject="MMDB Load Job Status" for i in `cat $Metafile` do if then email_address=`echo $i | cut -d":" -f2` /usr/lib/sendmail "$email_address" < $Email_File fi done } this is the send mail command i am using .please let me... (1 Reply)
Discussion started by: Alok K Yadav
1 Replies

4. Shell Programming and Scripting

Sending a file as an attachment to email

The file is located under appl/batchdata/ file name: storesales.txt I am using following code because uuencode is not present. I am not getting the data in file but i am getting the blank file with same name as an email attachment. ( echo "from: sch@xxxx.com" echo "to:sch@xxxx.com" echo... (2 Replies)
Discussion started by: skatpally
2 Replies

5. UNIX for Advanced & Expert Users

Sending mail with attachment

Hi, I am using Sun solaris OS unix server I am trying to send mail with an attachment using below script cat test.txt;uuencode test.txt test.txt|mailx -s "$subject" someone@somewhere I m getting mails but with no attachment. Hence i manipulate the script as below and i am... (2 Replies)
Discussion started by: sv0081493
2 Replies

6. Shell Programming and Scripting

sending an email with attachment

Hi, Please help me in sending an e-mail with attachment through unix mailx command is not present in our unix box. (4 Replies)
Discussion started by: dudd9
4 Replies

7. UNIX for Dummies Questions & Answers

Sending email with attachment and body

Hi I want to able to attach a file to a email and send it with a body the body of the email is within the "body" file, and the attachment in "atch" if i send like below it will send the email correctly /usr/sbin/sendmail me@you.com< body And when i send the attachment alone... (3 Replies)
Discussion started by: sridanu
3 Replies

8. Shell Programming and Scripting

Sending Email with Attachment

Hi, I want to send an email with multiple attachment using uuencode and mail command. I am able to send with one attachment Ex:uuencode abc.txt abc.txt | mail test@test.com -s "Test3" Can anyone reply with syntax. Regards BS (3 Replies)
Discussion started by: balajiora
3 Replies

9. Shell Programming and Scripting

sending an attachment through email

As a part of requirement I need to send out mails with attachment from UNIX. I have to take query the Oracle DB and send the result of the query in an attachment through mail. I use the following script for the same. #!/bin/csh #!/bin/bash #!/bin/ksh ATTFILE=/folder1/test.xls cd... (1 Reply)
Discussion started by: Sgiri1
1 Replies

10. UNIX for Dummies Questions & Answers

Sending attachment thru a mail

Is there any way we can send file attachemnts through mails from a unix server. Does the 'mail' command have such an option ?? (1 Reply)
Discussion started by: Rohini Vijay
1 Replies
Login or Register to Ask a Question
Email::Send::Test(3pm)					User Contributed Perl Documentation				    Email::Send::Test(3pm)

NAME
Email::Send::Test - Captures emails sent via Email::Send for testing SYNOPSIS
# Load as normal use Email::Send; use Email::Send::Test; # Always clear the email trap before each test to prevent unexpected # results, and thus spurious test results. Email::Send::Test->clear; ### BEGIN YOUR CODE TO BE TESTED (example follows) my $sender = Email::Send->new({ mailer => 'Test' }); $sender->send( $message ); ### END YOUR CODE TO BE TESTED # Check that the number and type (and content) of mails # matched what you expect. my @emails = Email::Send::Test->emails; is( scalar(@emails), 1, 'Sent 1 email' ); isa_ok( $emails[0], 'Email::MIME' ); # Email::Simple subclasses pass through DESCRIPTION
Email::Send::Test is a driver for use in testing applications that use Email::Send to send email. To be able to use it in testing, you will need some sort of configuration mechanism to specify the delivery method to be used, or some other way that in your testing scripts you can convince your code to use "Test" as the mailer, rather than "Sendmail" or another real mailer. How does it Work Email::Send::Test is a trap for emails. When an email is sent, it adds the emails to an internal array without doing anything at all to them, and returns success to the caller. If your application sends one email, there will be one in the trap. If you send 20, there will be 20, and so on. A typical test will involve doing running some code that should result in an email being sent, and then checking in the trap to see if the code did actually send out the email. If you want you can get the emails out the trap and examine them. If you only care that something got sent you can simply clear the trap and move on to your next test. The Email Trap The email trap is a simple array fills with whatever is sent. When you send an email, it is pushed onto the end of the array. You can access the array directly if you wish, or use the methods provided. METHODS
send $message As for every other Email::Send mailer, "send" takes the message to be sent. However, in our case there are no arguments of any value to us, and so they are ignored. It is worth nothing that we do NOTHING to check or alter the email. For example, if we are passed "undef" it ends up as is in the trap. In this manner, you can see exactly what was sent without any possible tampering on the part of the testing mailer. Of course, this doesn't prevent any tampering by Email::Send itself :) Always returns true. emails The "emails" method is the preferred and recommended method of getting access to the email trap. In list context, returns the content of the trap array as a list. In scalar context, returns the number of items in the trap. clear The "clear" method resets the trap, emptying it. It is recommended you always clear the trap before each test to ensure any existing emails are removed and don't create a spurious test result. Always returns true. deliveries This method returns a list of arrayrefs, one for each call to "send" that has been made. Each arrayref is in the form: [ $mailer, $email, @rest ] The first element is the invocant on which "send" was called. The second is the email that was given to "send". The third is the rest of the arguments given to "send". SUPPORT
All bugs should be filed via the CPAN bug tracker at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Email-Send-Test <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Email-Send-Test> For other issues, or commercial enhancement or support, contact the author. AUTHORS
Current maintainer: Ricardo SIGNES, <rjbs@cpan.org>. Original author: Adam Kennedy <cpan@ali.as>, <http://ali.as/> COPYRIGHT
Copyright (c) 2004 - 2005 Adam Kennedy. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.12.4 2011-08-31 Email::Send::Test(3pm)