Jump to content
cwoolsey

Powershell Script to run with AutoIt

Recommended Posts

I am trying to make a powershell script I have written run from an Autoit Script. I am trying to pass a parameter which will be the location of an excel document to send as an attachment.

The powershell will accept $attachment as a parameter, so I need to somehow run the filepath of the powershell script (and have it run not just open in notepad), and also pass in -attachment "<Filepath Name Here>" as the parameter. Anyone got any ideas?

Here is the powershell script:

param(
   [string]$attachment
)
############################################################################### 
 
###########Define Variables######## 
 
$fromaddress = "<email omitted>" 
$toaddress = "<email omitted>" 
$bccaddress = "" 
$CCaddress = "" 
$Subject = "Billing Form Action Required" 
$body = "Larry, 
The attached file is a billing document that needs to be approved.
Thank you!
Caleb Woolsey" 
$smtpserver = "<server omitted>" 
 
#################################### 
 
$message = new-object System.Net.Mail.MailMessage 

$message.From = $fromaddress 

$message.To.Add($toaddress) 
#$message.CC.Add($CCaddress) 
#$message.Bcc.Add($bccaddress) 
$message.IsBodyHtml = $True 
$message.Subject = $Subject 
$attach = new-object Net.Mail.Attachment($attachment) 
$message.Attachments.Add($attach) 
$message.body = $body 
$smtp = new-object Net.Mail.SmtpClient($smtpserver) 
$smtp.Send($message) 
 
#################################################################################

 

Edited by cwoolsey

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...