Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Working with Outlook templates


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Apr 16, 2015 4:52 AM Last Post By: Roy Godfrey
Roy Godfrey

Posts: 3
Registered: 8/16/13
Working with Outlook templates  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 16, 2015 3:44 AM
I have been struggling to find a way to edit an .oft or .msg Outlook template file.

I am able to call and send a file allowing the user to view before sending using the code below.

However there is certain text I would like to customise before the user sends for example the the greeting.

Is there a way to do this? Using HTML-body overwrites the contents of the template in my experience.

I am using XE7

// Fetch the template
template_blob := FDTable1.CreateBlobStream(FDTable1.FieldByName('et_template'),bmRead);
try
template_blob.Seek(0, soFromBeginning);
with TFileStream.Create('c:\fnb\gridlock\template.oft', fmCreate) do
try
CopyFrom(template_blob, template_blob.Size) ;
finally
Free ;
end;
finally
template_blob.Free;
end;


try
Outlook:=GetActiveOleObject('Outlook.Application') ;
MailItem := Outlook.CreateItemFromTemplate('c:\fnb\gridlock\template.oft') ; //('D:\Dev\Gridlock\Email Templates\Gridlock Generated Call Report.html') ;//
MailItem.Subject := 'subject here';
MailItem.Recipients.Add('roy dot godfrey at fnb dot co dot za');
// TO SHOW OUTLOOK DIALOG. BUT YOU HAVE SET MAILITEM.SEND AS COMMENT
MailInspector := MailItem.GetInspector;
MailInspector.display(FALSE); //true means modal

finally
Outlook := Unassigned;
end;

Robert Triest

Posts: 687
Registered: 3/24/05
Re: Working with Outlook templates  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 16, 2015 4:31 AM   in response to: Roy Godfrey in response to: Roy Godfrey
Is there a way to do this? Using HTML-body overwrites the contents of the template in my experience.
but what if you just read the Body text into a string variable, manipulate it and put it back into the Body?
Roy Godfrey

Posts: 3
Registered: 8/16/13
Re: Working with Outlook templates  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 16, 2015 4:52 AM   in response to: Robert Triest in response to: Robert Triest
Robert Triest wrote:
Is there a way to do this? Using HTML-body overwrites the contents of the template in my experience.
but what if you just read the Body text into a string variable, manipulate it and put it back into the Body?

Thanks, I am feeling a little stupid. Sometimes we over think things! Simple solution and it works perfectly
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02