Fraser Posted July 21, 2014 Share Posted July 21, 2014 Good Afternoon, I'm writing an app to create an outlook signature, so far I have it creating the HTML, Plain Text and part of the Rich Text signature however I'm stuck at adding an image to the RTF document. This is the code I have so far for the RTF part: $filename2 = $sigpath & "\" & $sigrtf $msg2 = "{\rtf1\ansi\ansicpg1252\deff0\deflang1030{\fonttbl{\f0\fswiss\fcharset0 Arial;}{\f1\froman\fcharset0 Arial;}}" & @CRLF $msg2 &= "{\colortbl ;\red0\green0\blue0;\red0\green0\blue255;}" & @CRLF $msg2 &= "{\*\generator Msftedit 5.41.15.1507;}" & @CRLF $msg2 &= "\line " & $salutation & @CRLF $msg2 &= "\line\line{\b " & $Firstname & " " & $lastname & "}" & @CRLF $msg2 &= "\line{\b " & $Description & "}" & @CRLF $msg2 &= "\line\line " & $department & @CRLF $msg2 &= "\line [Company Name]" & @CRLF $msg2 &= "\line " & $officelocation_rtf & @CRLF $msg2 &= "\line " & $PostalAddressrtf & @CRLF $msg2 &= "\line " & $phonertf & @CRLF $msg2 &= '\line {\field{\*\fldinst HYPERLINK "mailto:' & $emailaddress & '"}{\fldrslt\ul\cf2 ' & $emailaddress & '}}' & @CRLF $msg2 &= '\line {\field{\*\fldinst HYPERLINK "http:\\www.[Company Name].co.uk"}{\fldrslt\ul\cf2 www.[Company Name].co.uk}}' & @CRLF $msg2 &= "\line\line " & $dept_text_rtf & @CRLF $msg2 &= "\pard\cf1\f0\fs20" & @CRLF $msg2 &= "}" FileWrite($filename2, $msg2) I believe the image needs to be written in this format in RTF: \line {\rtf1 {\pict \dibitmap [Binary data] }} I've tried to get the binary data for the bitmap however that hasn't worked and I have tried to use _WinAPI_GetDIBits however I'm not entirely sure how this works. Can anyone help please? Link to comment Share on other sites More sharing options...
UEZ Posted July 21, 2014 Share Posted July 21, 2014 The image type must be in BMP format, further you need to read the image in binary format and finally trim left the binary string by 30. Something like this here: $binImage = StringTrimLeft(Binary(FileRead("YourImage.bmp")), 30) $binRtf = "{\rtf1{\pict\dibitmap\picw6218\pich3149\picwgoal3525\pichgoal1785 " & $binImage & "}}" Br, UEZ mLipok 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
water Posted July 21, 2014 Share Posted July 21, 2014 When you create a signature, Outlook saves a version for text, HTML and RTF mails. Please have a look at my OutlookEX UDF, function _OL_MailSignatureCreate and the _OL_MailSignatureCreate.au3 example. The example shows how to create a signature with formatted text, a table and an included image. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now