Solved

Help me with this complicated code

Posted on 2003-11-12
4
600 Views
Last Modified: 2007-12-19
1---------------------------------------------------------------------
{ Test whether MAPI is available - if not, raise an exception }
 
procedure TEmail.CheckMapi;
{$IFDEF RESSTRING}
resourcestring
{$ELSE}
const
{$ENDIF RESSTRING}
  SNoMapi = 'MAPI services are not available on this system';
begin
  if not MapiAvailable then { call function in SMAPI.PAS }
    raise EMapiUnavailable.Create(SNoMapi);
end;

2---------------------------------------------------------
procedure TEmail.DoMapiError(ErrorCode: Integer);
begin
  if Assigned(FOnMapiError) then
    FOnMapiError(Self, ErrorCode);
end;

if MapiResult <> SUCCESS_SUCCESS then
      DoMapiError(MapiResult);

Thanks, Luis
0
Comment
Question by:lfgmartins
  • 2
4 Comments
 
LVL 4

Expert Comment

by:kabix
ID: 9735730
What exactly the problem is?
0
 
LVL 2

Expert Comment

by:cero
ID: 9735732
hi Luis,

what's the question??

0
 

Author Comment

by:lfgmartins
ID: 9735876
Sry, what I want is if you please comment the code because I don't understand these lines of code.

- resourcestring
- raise EMapiUnavailable.Create(SNoMapi);
- FOnMapiError(Self, ErrorCode);
- DoMapiError(MapiResult);

Thanks,
Luis
0
 
LVL 2

Accepted Solution

by:
cero earned 500 total points
ID: 9736071
well, the first part

-resourcestring

{$IFDEF RESSTRING}
resourcestring
{$ELSE}
const
{$ENDIF RESSTRING}
  SNoMapi = 'MAPI services are not available on this system';

if a compilation constant RESSTRING is defined, SNoMapi is declared as resourcestring, and if it's not the case is a const.

note apart, resourcestring replaces LoadStr(), Delphi 3 introduced the possiblity to easily place constant strings as a resource with the new keyword 'resourcestring'.

-raise

The Raise keyword creates an exception object that is passed to the Delphi exception handler.

raise EMapiUnavailable.Create(SNoMapi);
creates/raises a exception, the exception object is the result of calling EMapiUnavailable.Create(SNoMapi) so this last call create an objetc.

- FOnMapiError(Self, ErrorCode);

FOnMapiError is a event error (an object), it is a member of TMapiControl, the exact type is TMapiErrEvent.
The arguments passed to the constructor of this object are "Self" and "ErrorCode", so I guess this object requires to be constructed two arguments, an object and a error code to raise and event informing an error. In some part of the code, this exception needs to be catched.

so the procedure TEmail.CheckMapi, check for a variable (boolean I guess) and if its not available, raise an exception with the text defined in SNoMapi

- DoMapiError(MapiResult);
Is a procedure whose only one functionality is to generate a event error (FOnMapiError)

regards

cero

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now