Using PowerShell to Copy the content of a Word Document and Paste that content into a New Message in Outlook

So, I'm a little new to PowerShell and I came across a PowerShell which allow me to copy the content od a spreadsheet, into the new message in Outlook 2007.  I have search and search on a way to do the same with a Word Document.  I would like to
create a PowerShell Script that copies the content of a Word Document and paste that content in an email message.
I am basing my script on this
#Create and get my Word Obj
$w1 = New-Object  -comobject Word.Application
$w1.Visible = $True
$UserWord = $w1.Workbooks.Open("C:\Users\hhhh\Documents\Powershell\test.docx")
#create outlook Object
$Outlook = New-Object  -comObject  Outlook.Application 
$Mail = $Outlook.CreateItem(0)
$Mail.SentOnBehalfOfName = "[email protected]"
$Mail.Recipients.Add("[email protected]")
#Add the text part I want to display first
$Mail.Subject = "Test email"
$Mail.Body = "My Comment on the Excel Spreadsheet"
#Then Copy the Word using parameters to format it
$Mail.Getinspector.WordEditor.Range().PasteExcelTable($true,$false,$false)
#Then it becomes possible to insert text before
$wdDoc = $Mail.Getinspector.WordEditor
$wdRange = $wdDoc.Range()
$Mail.Display()
Any Help would be great!

My requirements are the Word documents are a template of sorts.  The document will be changes prior to its email with some changes.  The other twist is that the customer might more that one recipients, and each recipient will have to have a separate
email, with the same content of the word document. 
For example: Say I'm doing maintenance. The Word doc might descript that maintenance, in a set format. Once save the script is run to generate 3 to 10 email with separate recipients with the body of the email containing what was in the Word document.

Similar Messages

  • Use Powershell to replace text with image in Word document

    I have a powershell script that uses a Word document as a template to create signatures that I am pushing out to my organization.
    The document is populated with text formatted the way I want the signature to look, that I then do a FindText and ReplaceText on.  This works fine for replacing text with text, but I can't figure out how to properly replace some of the holder text with
    an image and a link.  I found a few posts about adding images to word documents, but none that seem to work properly in this scenario.
    Any insight would be greatly appreciated, thanks!

    Dear BOFH,
    You are correct that method I outlined is not for inserting an image into a signature block (which would be in Outlook, not Word).  The links you post do certainly deal with outlook signatures, well done... Except that the question was about how to
    use a Powershell script to replace text in a Word document with an image.  Sure it was framed in the context of creating signatures, but the poster expressed that they already had a method of generating and replacing text, and just needed to know, as
    I did, how to do the thing they actually asked.
    Please BOFH... Please forgive my audacity in hoping to find a reference (any reference) to how to replace Word text with images via Powershell in a thread titled "Use Powershell to replace text with image in Word document".
    This is certainly a scripting question, and even something as simple as "You will need to call the .NET methods for the Word find/replace functionality.  Please ask in the Word forums for the correct method to use. 
    If you need help on calling .NET methods look HTTP ://here"support you offered combined with the contempt you offer in response to my actual substantive help to the actual question asked.
    BOFH, you are not better than us, just more arrogant.
    Can you please start your own question as this one has been closed.  Please see scripting guidelines.
    We cannot guarantee you satisfaction as this is a user supported forum.  The is no SLA for community support.  Perhaps if you posted a better worded question as a new topic someone might be able to help you resolve your issue.
    The topic you are posting on is closed and answered.
    ¯\_(ツ)_/¯

  • How do i copy the picture i made on photoshop and paste it on to word

    how do i copy the picture i made on photoshop and paste it on to word

    OK, Now I have word up and running. No edit menu. Poor memory...
    On the home tab at far left side is paste. Just below the paste button is a downward arrow which will give you other options for pasting. By default it will paste as a photoshop object. Which means you can not scale it but double clicking on will let you edit in photoshop. Clicking that downward arrow will let you do a paste special and the following dialog box will pop up.

  • I cant update my software as it always prompted me ,your start up disk is full and not enough space, when i had done the deleting some of my documents and stuff that i dont need it.

    i cant update my software as it always prompted me ,your start up disk is full and not enough space, when i had done the deleting some of my documents and stuff that i dont need it.

    I use CCleaner from the AppStore to delete the 'useless' stuff. It's free and works great for me

  • Is following message due to 'Java' setting left unchecked? Mac OSX supportsUser Authentication Mechanism (UAM) plug - ins from other manufacturers to control access to servers.To use a UAM, copy the plug - in to: Library/ Filesystems/ AppleShare/ Authenti

    Is following message due to 'Java' setting left unchecked?
    Mac OSX supportsUser Authentication Mechanism (UAM) plug - ins from other manufacturers to control access to servers.To use a UAM, copy the plug - in to: Library/ Filesystems/ AppleShare/ Authenti

    Man that is an ancient message.
    The last time I saw that was using Mac clients connected to a Microsoft (Windows) Server running 'Services for Macintosh' which included the ability to act as an AppleShare compatible file server. Because Microsoft have a different security system for defining accounts which includes the 'domain' as well as username, the standard Mac AFP client did not know how to send that information.
    Therefore Apple made it possible to installed a plugin in the form of a UAM or User Authentication Mechanism which added the ability to send this information to login to the fileserver.
    See http://support.microsoft.com/kb/101747
    However Microsoft have long discontinued 'Services for Macintosh' and now the only way for a Mac to connect to a standard Windows Server is via SMB not AFP. I don't believe this plugin is available to download anymore.

  • How to read the content of MS Word document?

    Hello Experts,
    I need to upload ms word document and fetch its content to an internal table.
    Is there any function module or class which is suitable to my requirement?
    Regards
    DNR Varma

    Dear DNR
    Look for class CL_CRM_DOCUMENTS in CRM. You can leverage this class to upload/download any type of document in CRM.
    Thanks
    Vishal

  • How do I copy and paste a drawing into a cell on a table?

    How do I copy a drawing (image) from one document and paste it into a table on another document?  I did do it and it looked good on the computer , saved the file and when I printed the drawing wasn't there.

    Sounds like you are not in Mountain Lion and have updated to Pages 5 on Mavericks.
    Images in cells ahs been removed by Apple along with over 90 other features in Pages 5.
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&sid=3527487677f0c 6fa05b6297cd00f8eb9&mforum=iworktipsntrick
    Pages '09 should still be in your Applications/iWork folder.
    Archive/trash Pages 5 and rate/review it in the App Store, then get back to work.
    Peter

  • Copy text out of multiple word documents

    Hi Guys,
    Just wondering if it is at all possible to copy ALL the text from multiple word documents and place it into one. So basically bringing 6+ documents into 1.
    I've done some google searches and have come a cross this:
    New-Object -comobject Word.Application
    But not sure if I can do what I want it to do. Any help/links would be a massive help.
    Cheers
    If this is helpful please mark it so. Also if this solved your problem mark as answer.

    You sir have saved my bacon! Thank you!
    If this is helpful please mark it so. Also if this solved your problem mark as answer.

  • I cannot see my Iphone 4 in my device window in the finder anymore.  It use to appear so I could copy the camera pictures off of it and transfer them to other folders.  Does anyone have and idea how to get it back when you plug it in initially.  Thanks

    I cannot see my Iphone 4 in my device window in the finder anymore.  It use to appear so I could copy the camera pictures off of it and transfer them to other folders.  Does anyone have and idea how to get it back when you plug it in initially.  Thanks

    You will want to open iPhoto, go to the iPhoto menu and select Preferences. Under the General tab, next to Connecting camera opens: select iPhoto. Close the preferences and quit iPhoto. Reconnect your iPhone 4. iPhoto should open automatically and offer to import your pictures. Import them and then do what you want with them.
    Best of luck.

  • SCOM2012 Need to use Powershell to reset the RUNAS Configuration account passwords

    I Need to use Powershell to reset the SCOM2012 RUNAS Configuration account passwords... could anyone help me with this?

    Hi BenStu,
    Have you checked the cmdlet
    "Update-SCOMRunAsAccount" to change the RunAs account password.
    This script is for your reference:
    $username = "<domain>/<user>"
    $password = cat C:\temp\securestring.txt | convertto-securestring
    $newcred = new-object System.Management.Automation.PsCredential $userName,$password
    Get-SCOMRunAsAccount –name "OMWindowsRunAsOM" | Update-SCOMRunAsAccount –RunAsCredential $newCred
    Refer to:
    Tracking down where Operations Manager stores information – Part 7               
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang

  • When i try to copy the DCIM carpet to my pc it says that it is unavailable i already in itunes set it in the summary to enabled disk use

    when i try to copy the DCIM carpet to my pc it says that it is unavailable i already in itunes set it in the summary to enabled disk use

    when i connected my ipod, iTunes pop a new window, that said that i needed to download the new software, I can't downloaded it cuz, the window said that there was an error and it was because the internet and other stuff,
    In the course of your troubleshooting to date, have you worked through the following document?
    iTunes for Windows: iTunes cannot contact the iPhone, iPad, or iPod software update server

  • Creating pdf files from word document and allow copying of content

    I generate word documents and then save them in PDF format before sending out to clients.  Sometimes these documents contain quite a lot of data in table format and I want my clients to be able to copy the data from the tables and be able to paste it into excel.  How do I save as PDF and still allow copying of content?
    Thanks

    Open such a PDF in Adobe Reader: File | Properties | tab Security.  It will tell you if copying is allowed or not.
    I don't know if you can change these security options from Word; you'll have to ask Microsoft.  To change them after the PDF was created, you will need Acrobat.

  • Is it possible to preserve the layer name when I copy and paste from Illustrator into Photoshop?

    Is it possible to preserve the layer name when I copy and paste from Illustrator into Photoshop?
    At the moment it just appears as "Vector Smart Object" in Photoshop and I have to take another step and change the layer name.
    Thank you!

    Not that I know. PS doesn't care for these kinds of things and uses its own naming system.
    Mylenium

  • Why is the right hand side of the tables on a Word document that was imported being cut off using Webhelp but not when using Webhelp Pro?

    I would prefer to use Webhelp and not Webhelp Pro because Webhelp allow for the insertion of a logo located to the right of the search field by selecting the "Show About" check box when generating content. The problem is that Webhelp is cutting off the words in the tables. Wordwrap is turned on in the Word document and the rest of the sentence will continue beneath the "cut off" word.

    You would only use WebHelp Pro if you were using RH Server – that’s what the “pro” versions of output are for. I would suggest that something’s wrong with your table definition. You talk about a Word document – is this the source or the output you’re talking about?

  • How do I copy and paste a webpage into keynote using my iPad?

    How do I copy and paste a webpage into keynote using my iPad?

    Sounds like you are not in Mountain Lion and have updated to Pages 5 on Mavericks.
    Images in cells ahs been removed by Apple along with over 90 other features in Pages 5.
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&sid=3527487677f0c 6fa05b6297cd00f8eb9&mforum=iworktipsntrick
    Pages '09 should still be in your Applications/iWork folder.
    Archive/trash Pages 5 and rate/review it in the App Store, then get back to work.
    Peter

Maybe you are looking for

  • Text formatting in mail!!!!!!!!! URGENT

    hello, i am using JavaMail API. i want to format my text which will be in body of mail. e.g if if enter <b></b> then it should make that text bold. basicaaly i want support for <b><br><u><i> etc.......... now wht is happening is if i enter <b>Hello <

  • How can i configure STMS with out physical systems

    Dear Experts , please solve my doubts here i installed one system in AIX and named it as DEV system in that system i need to perform post-installaion Activities and i started some activities also presently my doubt is in STMS configuration here i hav

  • Concern in published SWF file using Presenter for PPTX

    I observed that the PPT files (2003 version) which were published using Presenter 7 were creating a SWF file containing multiple frames. However the PPTX files (2007) which were published using Presenter 7 were creating a SWF file containing single f

  • Selection group in MRP run MD01

    Dear all, While running MD01, It displays the selection group 1,2,3,4,5,6,7,8 What is this selection group, what is the meaning , Sometime these numbers are in red, what does it indicate Please guide me Subbu.

  • Install AWUS036H onto Mac OS X 10.8

    do anyone know a way to install AWUS036H on OS X 10.8??