Sign in to follow this  
Followers 0
Fraser

Add image to RTF document

3 posts in this topic

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?

Share this post


Link to post
Share on other sites



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

1 person likes this

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

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 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