pasting text and excel selections into outlook

Welcome Forums General PowerShell Q&A pasting text and excel selections into outlook

Viewing 4 reply threads
  • Author
    Posts
    • #196877
      Participant
      Topics: 3
      Replies: 3
      Points: 38
      Rank: Member

      I’m working on a script to insert a few lines of text into a new outlook email, then a couple blank lines, then a selection from excel.

      I can do either or correctly. That is, paste the text, or paste the selection.

      But trying to do both and not have the table obliterate the previously pasted text, or have the selection pasted in as a bunch of . System.__ComObject lines is proving tricky. set-clipboard and get-clipboard work very, very poorly with excel.

      Ideally I’d paste the leading text. Then get the selection from excel. Then paste that in with one or two blank lines between it and the leading text, and then have the signature show up correctly.

      thanks!

    • #196889
      Participant
      Topics: 15
      Replies: 1761
      Points: 3,167
      Helping Hand
      Rank: Community Hero

      Are you sure that is the only way to accomplish what you want to do? If the goal is to provide a email with text and a table, you should consider another approach. Look at a simple example (make sure you use the Gist link if you post any HTML\XML):

      https://gist.github.com/rasimmers/fbfb75dbae73264bc7c91682ad733a5d

      If you leverage HTML, you can format as much as you want, you just need to ensure it works with the mail clients. You can get some ideas in this ebook.

    • #196997
      Participant
      Topics: 3
      Replies: 3
      Points: 38
      Rank: Member

      The source data isn’t an entire table, it’s rows in an existing table in a spreadsheet. The number of rows can change weekly, so hardcoding a number in, or just dumping the table won’t work. So the manual selection is required. There’s any number of different email destinations involved, so that’s a human process as well, although choosing from a list is pretty easy to code up.

      The reasons for using outlook are first, the person who’d be using this is familiar and comfortable with it. Secondly, displaying the message gives them a chance to sanity-check before sending, making sure they’re not sending the wrong data to the wrong email address, and thirdly, if they need to pull a copy of an older email up, that’s much easier for a non-technical person to do in outlook.

    • #197018
      Participant
      Topics: 3
      Replies: 3
      Points: 38
      Rank: Member

      Figured it out:

    • #197042
      Participant
      Topics: 15
      Replies: 1761
      Points: 3,167
      Helping Hand
      Rank: Community Hero

      Glad you figure it out!!

      • This reply was modified 8 months, 2 weeks ago by Rob Simmers.
Viewing 4 reply threads
  • The topic ‘pasting text and excel selections into outlook’ is closed to new replies.