Hi AHK World
Im Try to insert table in a New Email Outlook
m := ComObjCreate("Outlook.Application").CreateItem(0)
m.Subject := "Hi There"
m.To := "maldonda" "`;" "rodrigu11"
;~ m.table ???????????
m.Body :="Here is the body... `n`n" var3 "And the really cool thing about using this method, `n`n`n`n`n`n is, you can have what ever you want as the body and `n`n`n`n`n`n not worry about how long it is...or worry about the non-formatting issues that come from the mailto: command`n`n`n`n ...yes, that is a whole bunch of new Lines to show you how you can format this however you want...`n`n`n`n`n`n`n`n AND IT WORKS"
m.Display ;to display the email message...and the really cool part, if you leave this line out, it will not show the window............... but the m.send below will still send the email!!!
;~ m.Send ;to automatically send and CLOSE that new email window...
I find this document
https://msdn.microsoft.com/en-us/librar ... 60769.aspx
But I Do no t understand how to translated to AHK
Outlook Table Topic is solved
Re: Outlook Table
There is no built in method that inserts a table into an Outlook message unless you also have Word or Excel.
You can however inject the table markup directly using the HTMLbody property ( docs: https://msdn.microsoft.com/en-us/librar ... 68941.aspx )
Here's that approachthis is a simple example that doesn't add headings, captions, extra formatting etc to the table..
for more info on table markup do a google search, there's a lot of info out there on them cause they are really old
hope this helps
You can however inject the table markup directly using the HTMLbody property ( docs: https://msdn.microsoft.com/en-us/librar ... 68941.aspx )
Here's that approach
Code: Select all
m := ComObjCreate("Outlook.Application").CreateItem(0)
m.Display
m.To := "maldonda" "`;" "rodrigu11"
m.Subject := "Hi There"
tabledata :=[ [ "a", "b", "c" ], [ "d", "e" ,"f" ], [ "g", "h" ,"i" ] ] ; example array
m.HTMLbody := AddTable( tabledata )
m.HTMLbody .= "more stuff" ; to add the body text etc with the table you must concatenate!
; m.Send
return
; AddTable( columns [ default 3 ], rows [ default 3 ], width [ default 50 ], height [ default 10 ], padding [ default 2 ] )
AddTable( tdata = "", w = 50, h = 10, p = 2 )
{
if !IsObject( tdata )
tdata := [["","",""],["","",""],["","",""]]
style =
(
<style> .tbl { border:1px solid #000; border-collapse:collapse; }
.tbl th { border:1px solid #000; } .tbl td { border:1px solid #000; }
.tbl td { width: %w%px; height: %h%px; padding: %p%px; } </style>
)
table_html = <table class="tbl"><thead></thead><tbody>
for each, row in tdata
{
for i in ( row, tables .= "</tr><tr>" )
tables .= "<td>" (( r:=row[ i ] ) = "" ? " " : r ) "</td>"
}
return style . table_html . SubStr(tables,6) "</tr></tbody></table>"
}
for more info on table markup do a google search, there's a lot of info out there on them cause they are really old
hope this helps
Re: Outlook Table
thanks TLM it wokrs fine
Re: Outlook Table
Hello,
You have proposed great solution here, however I cannot get my mind around how to insert table in between text.
Text
Table
Text
If I go this way
Text on the top does not appear..... not sure what I am doing wrong
How could I find a solution for this?
You have proposed great solution here, however I cannot get my mind around how to insert table in between text.
Text
Table
Text
If I go this way
Code: Select all
m.HTMLbody := "more stuff"
tabledata :=[ [ "a", "b", "c" ], [ "d", "e" ,"f" ], [ "g", "h" ,"i" ] ] ; example array
m.HTMLbody .= AddTable( tabledata )
m.HTMLbody .= "more stuff"
How could I find a solution for this?
- king-of-hearts
- Posts: 30
- Joined: 01 Oct 2017, 06:29
Re: Outlook Table
Using the code from TLMdominicx wrote:Hello,
You have proposed great solution here, however I cannot get my mind around how to insert table in between text.
Text
Table
Text
If I go this wayText on the top does not appear..... not sure what I am doing wrongCode: Select all
m.HTMLbody := "more stuff" tabledata :=[ [ "a", "b", "c" ], [ "d", "e" ,"f" ], [ "g", "h" ,"i" ] ] ; example array m.HTMLbody .= AddTable( tabledata ) m.HTMLbody .= "more stuff"
How could I find a solution for this?
Code: Select all
m := ComObjCreate("Outlook.Application").CreateItem(0)
m.Display
m.To := "maldonda" "`;" "rodrigu11"
m.Subject := "Hi There"
; --------------------------------------------------
tabledata := [[ "a", "b", "c" ], [ "d", "e" ,"f" ], [ "g", "h" ,"i" ]] ; example array
m.HTMLbody := "stuff" ; first text
m.HTMLbody .= AddTable(tabledata) ; table in the middle
m.HTMLbody .= "more stuff" ; second part
; --------------------------------------------------
; m.Send
return
; --------------------------------------------------
; AddTable( columns [ default 3 ], rows [ default 3 ], width [ default 50 ], height [ default 10 ], padding [ default 2 ] )
AddTable( tdata = "", w = 50, h = 10, p = 2 )
{
if !IsObject( tdata )
tdata := [["","",""],["","",""],["","",""]]
style =
(
<style> .tbl { border:1px solid #000; border-collapse:collapse; }
.tbl th { border:1px solid #000; } .tbl td { border:1px solid #000; }
.tbl td { width: %w%px; height: %h%px; padding: %p%px; } </style>
)
table_html = <table class="tbl"><thead></thead><tbody>
for each, row in tdata
{
for i in ( row, tables .= "</tr><tr>" )
tables .= "<td>" (( r:=row[ i ] ) = "" ? " " : r ) "</td>"
}
return style . table_html . SubStr(tables,6) "</tr></tbody></table>"
}
https://autohotkey.com/boards/viewtopic.php?f=6&t=38707 - MS Access Manager - SQL Query: Incredible tool for MS Access/SQL Queries on the fly!!
Re: Outlook Table
Thanks a lot king-of-hearts. This works!
How interesting that inserting tabledata: in between breakes the syntax altogether, however keeping it on top does not.... I wonder why?
How interesting that inserting tabledata: in between breakes the syntax altogether, however keeping it on top does not.... I wonder why?
- FanaticGuru
- Posts: 1907
- Joined: 30 Sep 2013, 22:25
Re: Outlook Table
I don't know about that. It seems as built in as anything else in Office.TLM wrote:There is no built in method that inserts a table into an Outlook message unless you also have Word or Excel.
Code: Select all
olApp := ComObjActive("Outlook.Application")
olMailItem := olApp.CreateItem(0) ; olMailItem := 0
olMailItem.display
olInspector := olApp.ActiveInspector.WordEditor.Application.ActiveDocument
olTable := olInspector.Tables.Add(olInspector.Range, 6, 7, 1, 0) ; Range, NumRows, NumColumns, DefaultTableBehavior, AutoFitBehavior
olTable.Cell(1,1).Range.Text := "First Cell"
olTable.Cell(3,2).Range.Text := "Three Down, Two Over"
The table is pretty much the same type as you would expect in any Office product and can be manipulated as such. It can be a lot easier to put stuff into the table as you can access it by cell coordinates.
Outlook comes with a watered down version of Word as its editor so Word does not have to be installed although I have never had an installation of Outlook without Word also installed.
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Outlook Table
Nicely done FanaticGuru
Who is online
Users browsing this forum: Bing [Bot], windmaya and 120 guests