CreateItemFromTemplate in VLC

Add-in Express™ Support Service
That's what is more important than anything else

CreateItemFromTemplate in VLC
 
Giancarlo


Guest


i want open a msg file
i think that i must use CreateItemFromTemplate

http://stackoverflow.com/questions/30908788/open-outlook-mail-msg-file-using-vba-from-excel

https://www.add-in-express.com/creating-addins-blog/2011/08/31/outlook-create-message-based-on-template/

My problem is on object type
( E2010 Incompatible types: '_MailItem' and 'IDispatch' )

I need something like this


var
  FMail: TMailItem;
  IMail : IDispatch;
begin
      FMail := OutlookApp.CreateItemFromTemplate(Dir + 'm.msg');
      FMail.Display();
end;


but I'm not able to use the addIn objects
Posted 31 Aug, 2016 10:00:30 Top
Giancarlo


Guest


I think solved


      ns := OutlookApp.GetNamespace('MAPI');
      containerFolder := ns.GetDefaultFolder(olFolderInbox);
      FMail := OutlookApp.CreateItemFromTemplate(filename, containerFolder)  as TMailItem;
Posted 31 Aug, 2016 11:16:36 Top
Giancarlo


Guest


I need your help.
The 3?? line got this error:

Interface not supported

OLE Error 80040108

Can you help me?
Posted 01 Sep, 2016 07:38:06 Top
Giancarlo


Guest


I have solved
Ok the solution is this:


  IMail : IDispatch;
  ns : _NameSpace;
  containerFolder : MAPIFolder;


  ns := OutlookApp.GetNamespace('MAPI');
  containerFolder := ns.GetDefaultFolder(olFolderInbox);
  IMail := OutlookApp.CreateItemFromTemplate(filename, containerFolder)  ;
Posted 01 Sep, 2016 07:48:55 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Giancarlo,

Thank you for letting us know.


Andrei Smolin
Add-in Express Team Leader
Posted 01 Sep, 2016 08:20:45 Top