cwoolsey Posted September 3, 2015 Posted September 3, 2015 (edited) 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 September 3, 2015 by cwoolsey
ViciousXUSMC Posted September 3, 2015 Posted September 3, 2015 if you want to use AutoIT you may want to look at the Outlook or other mail UDF's that we have access to.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now