Board index » delphi » OLE automation with Outlook

OLE automation with Outlook

Hi,

I'm writing an application in C++ that needs to send a standard reply to
all the mails in a specific input box of the Outlook Express, one by one.
Does it can be done using OLE automation? I had found a lot of examples of
automation with Microsoft's Word and Excel. Can Anybody  tell anything about
automation with Outlook? Any example in C++ or Delphi would be excellent!
Thanks a lot.

Marcos Artur
ar...@pointersoftware.com.br

 

Re:OLE automation with Outlook


artur wrote

Quote
>Does it can be done using OLE automation? >
>Marcos Artur
>ar...@pointersoftware.com.br

Look down the list a little ways.. Subject := here is how to automate
outlook
hope this helps

Re:OLE automation with Outlook


artur a crit dans le message <6tje1n$o...@forums.borland.com>...

Quote
>Hi,

>I'm writing an application in C++ that needs to send a standard reply to
>all the mails in a specific input box of the Outlook Express, one by one.
>Does it can be done using OLE automation? I had found a lot of examples of
>automation with Microsoft's Word and Excel. Can Anybody  tell anything
about
>automation with Outlook? Any example in C++ or Delphi would be excellent!
>Thanks a lot.

>Marcos Artur
>ar...@pointersoftware.com.br

Have a look at http://www.microsoft.com/outlookdev/articles/movs105.htm
you will find some examples using VB to communicate with exchange. After
that, you will have to import the Outlook TLB and try to do the same with
the Com objects (in delphi or C++ Builder).

Re:OLE automation with Outlook


Outlook Express and Outlook are two entirely different programs.  You can
automate Outlook 97/98 pretty easily, but Outlook Express doesn't support
OLE Automation, to the best of my knowledge.  If you can do your project in
Outlook 98, then it'll be a snap.  If you're going to be reading the Outlook
mail folders, make sure you create an OLE variant for the MAPI NameSpace
like this:

procedure TMainForm.Button2Click(Sender: TObject);
var
  MSOutlook, olNameSpace, olinBox, olOutBox, olSentMail : OleVariant;
begin
  Screen.Cursor := crHourGlass;

  try
    if VarType(MSOutlook) = VarEmpty then
      MSOutlook := CreateOleObject('Outlook.Application'); {if Outlook has
been killed, restart}

    olNameSpace := MSOutlook.getNameSpace('MAPI');
    olinBox := olNameSpace.GetDefaultFolder(olFolderInbox);
    olOutBox := olNameSpace.GetDefaultFolder(olFolderOutbox);
    olSentMail := olNameSpace.GetDefaultFolder(olFolderSentMail);

    Label2.Caption := 'Checking Inbox...                    ';
    Label2.repaint;
    Label2.Tag := olinBox.Items.Count;
    Label2.Caption := 'Received Messages: '+IntToStr(Label2.Tag)+'    ';
    Label2.repaint;

    Label3.Caption := 'Checking Outbox...                    ';
    Label3.repaint;
    Label3.Tag := olOutBox.Items.Count;
    Label3.Caption := 'Queued Messages: '+IntToStr(Label3.Tag)+'    ';
    Label3.repaint;

    Label4.Caption := 'Checking Sent Items...                    ';
    Label4.repaint;
    Label4.Tag := olSentMail.Items.Count;
    Label4.Caption := 'Sent Messages: '+IntToStr(Label4.Tag)+'        ';
    Label4.repaint;

    olSentMail := UnAssigned;
    olOutBox := UnAssigned;
    olNameSpace := UnAssigned;
  except
    on E:EOleException do begin
      RichEdit1.Lines.Add(DateTimeToStr(Now)+' '+E.Message);
      MSOutlook := UnAssigned;
    end; {on E:}
  end; {try..except}

  Screen.Cursor := crDefault;

end;

Good luck!
Reece Watkins

Quote
artur wrote in message <6tje1n$o...@forums.borland.com>...
>Hi,

>I'm writing an application in C++ that needs to send a standard reply to
>all the mails in a specific input box of the Outlook Express, one by one.
>Does it can be done using OLE automation? I had found a lot of examples of
>automation with Microsoft's Word and Excel. Can Anybody  tell anything
about
>automation with Outlook? Any example in C++ or Delphi would be excellent!
>Thanks a lot.

>Marcos Artur
>ar...@pointersoftware.com.br

Other Threads