Sign in to follow this  
Followers 0
Seminko

Outlook message - clip put - paste (tables)

22 posts in this topic

#1 ·  Posted (edited)

Hey fellas,

I'm trying to create a tool for one of our teams. When we deliver an order we send the customer an email with a few pieces of data we pull from the order form.

So I have this email template with tables. When I copy it and paste it into outlook it pastes the email with all the tables. But the thing is, I need to fill it out first. Is there a way for to set the email for ClipPut so that is retains the table format it is in right now?

If so, is there a way for it to be updated and still retain the format?

If not, any other suggestion? Do you know a community around VBA that could help me?

(obviously this would be much easier via VBA, but unfortunately, I'm a VBA noob)

Thanks!

PS: Happy holidays :)

Edited by Seminko

Share this post


Link to post
Share on other sites



Is there a way for to set the email for ClipPut so that is retains the table format it is in right now?

Clipput and clipget should retain whatever information you pass it.  So yes.

 

If so, is there a way for it to be updated and still retain the format?

 

Before you clipput the information into the email, change the variables.

It might help to do a search for 'parsing' in the autoit forums.  I recommend you take a stab at writing the program yourself and post your code, then we can help you further. 

Share this post


Link to post
Share on other sites

Before you clipput the information into the email, change the variables.

 

That's the thing ClipPut resets the format... When I copy the email body, ClipGet, do a StringReplace, ClipPut and then paste it, the table format gets lost.

Share this post


Link to post
Share on other sites

I'm almost certain that ClipPut and ClipGet only work on strings and not anything formatted. You'd need to use the Clipboard UDF to work with anything other than text.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

You'd need to use the Clipboard UDF to work with anything other than text.

 

Just googled and found one Clipboard UDF which appears only to be checking if a clipboard was updated or not. Nothing else...

Share this post


Link to post
Share on other sites

I thinh BrewManNH means the already present Clipboard.au3 in AutoIt.
#include <Clipboard.au3>
have a look to _ClipBoard_SetDataEx function in help and also to other _ClipBoard* functions


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Ah, thanks. Well the $iFormat doesn't seem to include tables.

Share this post


Link to post
Share on other sites

 

When we deliver an order we send the customer an email with a few pieces of data we pull from the order form.

Just curious as to what the order form is (i.e. HTML, Word, Excel)?  It could make a difference in terms of options to maintain the formatting.


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Did you have a look at the OutlookEX UDF? It allows to create a new mail based on a template. It should then be easy to change the content of the table.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Did you have a look at the OutlookEX UDF? It allows to create a new mail based on a template. It should then be easy to change the content of the table.

Was not sure if it was possible. So I create a template in Outlook and then write a script using OutlookEX to prepopulate certain fields in such template?

Share this post


Link to post
Share on other sites

Correct. Add placeholders (e.g. %1%, %2% etc.) where you need to insert variable data. Open a new mail item using _OL_ItemCreate and pass the template. Retrieve the property "Body" or "HTMLBody" using _OL_ItemGet, replace the placeholders with your variable data (StringReplace) and set the propery by using _OL_ItemModify again. (I am on vacation right now so the function names might be slightly different).


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

How do I pass the template though? I though I would create an Outlook template and set some kind of a parameter to _OL_ItemCreate for it to open the template.

Share this post


Link to post
Share on other sites

IIRC _OL_ItemCreate has a parameter to pass the template name.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

To be precise: It is parameter 4 of function _OL_ItemCreate :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Right, back from holidays. BTW, happy new year everyone.

So I chewed throught the template stuff but still can't wrap my head around the placeholders and parameters.

I got this:

#Include <OutlookEX.au3>
#Include <Array.au3>

Global $oOL = _OL_Open()
Global $oItem = _OL_ItemCreate($oOL, $olMailItem, "", "C:\Users\template.oft")
Global $Property = _OL_ItemGet($oOL, $oItem, "", "Body")
$PropertyUpd = StringReplace($Property[1][1], "OrderServiceSpeed", "S T U F F")

Now I would Item Update but there are those parameters that I don't know how to set up.

Edited by Seminko

Share this post


Link to post
Share on other sites

Try:

_OL_ItemModify($oOL, $oItem, Default, "Body=" & $PropertyUpd)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Right, that works... but again, it totally messes up the email formatting and pastes everything as text.

When you do StringReplace you lose all the formatting.

Any idea how to get around that?

Share this post


Link to post
Share on other sites

Replace the property "Body" with "HTMLBody".

"Body" only contains the text part of the body.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

SPLENDID!!!

Will it work on PCs that do not have admin rights? Read somewhere there might be an issue. Just hope there won't with simple stuff like this. :)

Thanks water!

Share this post


Link to post
Share on other sites

No admin rights needed up to Outlook 2010. Don't know if Outlook 2013 behaves the same way.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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
Sign in to follow this  
Followers 0