Created
January 28, 2010 18:40
-
-
Save gsherman/289007 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. .\CreateClarifyApplicationAndLogin.ps1 | |
$rmaNumber = "000045-1"; | |
$path = "C:\temp\$rmaNumber.doc" | |
If (Test-Path $path){ remove-item $path -Force; } | |
$smtpServer="emailServer" | |
$To="someone@company.com" | |
$From="someone_else@company.com" | |
$Subject="Details for RMA $rmaNumber" | |
$Body="Details for RMA $rmaNumber" | |
$ClarifySession = $ClarifyApplication::Instance.CreateSession() | |
$dataSet = new-object FChoice.Foundation.Clarify.ClarifyDataSet($ClarifySession) | |
$rmaGeneric = $dataSet.CreateGeneric("req_sum") | |
$rmaGeneric.AppendfIlter("rma_number","equals",$rmaNumber) | |
$rmaGeneric.Query() | |
$rmaDataRows = $rmaGeneric.Rows | |
$rma = $rmaDataRows[0] | |
$siteName = $rma["site_name"]; | |
$requestDate = $rma["request_date"]; | |
$requestStatus = $rma["request_status"]; | |
$partNumber = $rma["part_number"]; | |
#[ref]$SaveFormat = "microsoft.office.interop.word.WdSaveFormat" -as [type] | |
$word = New-Object -ComObject word.application | |
$word.visible = $false | |
$doc = $word.documents.add() | |
$word = New-Object -comobject word.application | |
$word.Visible = $false | |
$doc = $word.Documents.Add() | |
$paragraph = $doc.Paragraphs.Add() | |
$paragraph.Range.Style = "Heading 1" | |
$paragraph.Range.Text = "Details for RMA Number: $rmaNumber"; | |
$paragraph.Range.InsertParagraphAfter() | |
$paragraph = $doc.Paragraphs.Add() | |
$paragraph.Range.Text = "Part Number: $partNumber"; | |
$paragraph.Range.InsertParagraphAfter() | |
$paragraph = $doc.Paragraphs.Add() | |
$paragraph.Range.Text = "Site Name: $siteName"; | |
$paragraph.Range.InsertParagraphAfter() | |
$paragraph = $doc.Paragraphs.Add() | |
$paragraph.Range.Text = "Status: $requestStatus"; | |
$paragraph.Range.InsertParagraphAfter() | |
$doc.saveas($path); #,$saveFormat::wdFormatDocument) | |
#$filename = $doc.FullName + ''; | |
$doc.close() | |
$word.quit() | |
$msg = new-object Net.Mail.MailMessage | |
$att = new-object Net.Mail.Attachment($path) | |
$smtp = new-object Net.Mail.SmtpClient($smtpServer) | |
$msg.From = $From | |
$msg.To.Add($To) | |
$msg.Subject = $Subject | |
$msg.Body = $Body | |
$msg.Attachments.Add($att) | |
$smtp.Send($msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment