Manuals - MAPI

Emma

Member
Hi, Does anyone know where i can find documentation relating to MAPI for Progress? Please help!
 

Emma

Member
Re: Re: Manuals - MAPI

Originally posted by GordonRobertson


The MSDN library at http://msdn.microsoft.com/library contains a decent reference to the CDO libraries. The dotr site http://www.dotr.com contains some progress examples.

Gordon

thanks for replying.

I have tried both these urls previous to my posting here. I cannot find anything that i can use with Progress. It all seems to be either C or VB. Do you know anywhere i could get a manual on Mapi for Progress, or something similar?

:confused:
 

GordonRobertson

New Member
The dotr site has a file called ole_mess.zip in the downloads section, which is a word document on using MAPI with Progress.

Gordon
 

Emma

Member
MAPI - manuals

Originally posted by GordonRobertson
The dotr site has a file called ole_mess.zip in the downloads section, which is a word document on using MAPI with Progress.

Gordon

I have tried here too. I am wanting info on sending an email to multiple recipients. This site does not contain that information. Thanks anyway.

:wavey:
 

NickA

Member
Multiple recipients? No problem!

When you're sending to multiple recipients in Outlook or whatever, you separate multiple recipients with EG a semi-colon. The same applies here. EG to send to 'john@domain.com' and 'jane@domain.com', fill in the 'To' property as 'john@domain.com;jane@domain.com'.

BTW: As Gordon previously stated, MSDN and dotr are the best places to go looking for this kind of stuff - but you need to dig a little. Another site I've found useful for messing about with MS/Progress is www.global-shared.com
 

Emma

Member
Re: Multiple recipients? No problem!

Originally posted by NickA
When you're sending to multiple recipients in Outlook or whatever, you separate multiple recipients with EG a semi-colon. The same applies here. EG to send to 'john@domain.com' and 'jane@domain.com', fill in the 'To' property as 'john@domain.com;jane@domain.com'.

BTW: As Gordon previously stated, MSDN and dotr are the best places to go looking for this kind of stuff - but you need to dig a little. Another site I've found useful for messing about with MS/Progress is www.global-shared.com

Thanks, but i already knew that. The thing is with mapi, it is hard to resolve whether a recipient is a to, cc, or bcc recipient. it creates an array which is very difficult to access from progress. in this array it holds the recipient name and class, among other things. what i have to do is chop up the long string in the array into it's various components and then use these to send the message. I can get it to send messages to the to, cc and bcc recipients, but i can't get it to send them all via on email, it has to send individual emails, which only display the particular recipients name, so a cc recipient is not shown the to recipient. Does this make sense. What i am trying to do is send just one email with everyone on it.

:confused:
 

NickA

Member
Are you using the native MAPI API?

I've never used the native API (It's a bit complicated), preferring to use the simpler option of OLE (Which is documented on the dotr site).

If you're using the native API, then as you've probably guessed you'll need to use MEMPTR variables to build structures to pass to the API. www.global-shared.com has just the examples you're looking for - take a look at the 'MAPI and TAPI' section, heading 'A MAPI approach with one attachment' and the 'Theory' section, heading 'Passing complex structures'.

Also look on MSDN:
Messaging API.

The bit that separates a normal recipient from a CC, BCC etc. appears to be the 'recipient class', or object/property 'MapiRecip.RecipClass'. Property values are (1)To, (2)Cc,(3)BCc.

HTH
 

Samj

Member
Emma

I've been playing around with this problem and I believe I may have a solution if you're still in need.

From the sample at:

http://www.global-shared.com/api/index.htm

Add:
&Scoped-define STRUCT-SIZE 24
DEFINE VARIABLE ndx AS INTEGER NO-UNDO.
DEFINE VARIABLE num-structs AS INTEGER NO-UNDO.

Modify:
DEFINE VARIABLE RecipNamePtr AS MEMPTR EXTENT 10. /* or whatever the limit is */

/* -----Build Recipient details ----- */
SET-SIZE(RecipDescPtr) =
(25 * NUM-ENTRIES(RecipName,";")).
DO ndx = 1 TO NUM-ENTRIES(RecipName,";"):
SET-SIZE(RecipNamePtr[ndx]) = LENGTH(ENTRY(ndx,RecipName,";")) + 1.
/* maximum = 255 */
PUT-STRING(RecipNamePtr[ndx],1) = ENTRY(ndx,RecipName,";").
/* Recipient name */
PUT-LONG(RecipDescPtr,( 1 + ws-num-structs)) = 0. /* Reserved */
PUT-LONG(RecipDescPtr,( 5 + ws-num-structs)) = 1. /* RecipClass 1 = MAPI_TO */
PUT-LONG(RecipDescPtr,( 9 + ws-num-structs)) = GET-POINTER-VALUE(RecipNamePtr[ndx]).
/* Name */
PUT-LONG(RecipDescPtr,(13 + ws-num-structs)) = 0. /* Address */
PUT-LONG(RecipDescPtr,(17 + ws-num-structs)) = 0. /* EID Size */
PUT-LONG(RecipDescPtr,(21 + ws-num-structs)) = 0. /* Entry ID */
ASSIGN
num-structs = num-structs + {&STRUCT-SIZE}.
END.

/* ----- Build Message Details ----- */
SET-SIZE(MessageDescPtr) =
45 + (NUM-ENTRIES(RecipName,";") * 4).
PUT-LONG(MessageDescPtr,33) = NUM-ENTRIES(RecipName,";").
/* RecipCount */

Call with multiple recips -

RUN mapi(INPUT "you@work.com",
INPUT "john@domain.com;jane@domain.com",
INPUT "late for dinner",
INPUT "something came up..",
INPUT "c:\images\flowers.bmp").

DO ndx = 1 TO 10:
SET-SIZE(RecipNamePtr[ndx]) = 0.
END.

Hope this helps,

Sam
 

Emma

Member
Re: Emma

Originally posted by Samj
I've been playing around with this problem and I believe I may have a solution if you're still in need.

From the sample at:

http://www.global-shared.com/api/index.htm

Add:
&Scoped-define STRUCT-SIZE 24
DEFINE VARIABLE ndx AS INTEGER NO-UNDO.
DEFINE VARIABLE num-structs AS INTEGER NO-UNDO.

Modify:
DEFINE VARIABLE RecipNamePtr AS MEMPTR EXTENT 10. /* or whatever the limit is */

/* -----Build Recipient details ----- */
SET-SIZE(RecipDescPtr) =
(25 * NUM-ENTRIES(RecipName,";")).
DO ndx = 1 TO NUM-ENTRIES(RecipName,";"):
SET-SIZE(RecipNamePtr[ndx]) = LENGTH(ENTRY(ndx,RecipName,";")) + 1.
/* maximum = 255 */
PUT-STRING(RecipNamePtr[ndx],1) = ENTRY(ndx,RecipName,";").
/* Recipient name */
PUT-LONG(RecipDescPtr,( 1 + ws-num-structs)) = 0. /* Reserved */
PUT-LONG(RecipDescPtr,( 5 + ws-num-structs)) = 1. /* RecipClass 1 = MAPI_TO */
PUT-LONG(RecipDescPtr,( 9 + ws-num-structs)) = GET-POINTER-VALUE(RecipNamePtr[ndx]).
/* Name */
PUT-LONG(RecipDescPtr,(13 + ws-num-structs)) = 0. /* Address */
PUT-LONG(RecipDescPtr,(17 + ws-num-structs)) = 0. /* EID Size */
PUT-LONG(RecipDescPtr,(21 + ws-num-structs)) = 0. /* Entry ID */
ASSIGN
num-structs = num-structs + {&STRUCT-SIZE}.
END.

/* ----- Build Message Details ----- */
SET-SIZE(MessageDescPtr) =
45 + (NUM-ENTRIES(RecipName,";") * 4).
PUT-LONG(MessageDescPtr,33) = NUM-ENTRIES(RecipName,";").
/* RecipCount */

Call with multiple recips -

RUN mapi(INPUT "you@work.com",
INPUT "john@domain.com;jane@domain.com",
INPUT "late for dinner",
INPUT "something came up..",
INPUT "c:\images\flowers.bmp").

DO ndx = 1 TO 10:
SET-SIZE(RecipNamePtr[ndx]) = 0.
END.

Hope this helps,

Sam

Sam,

I have tried the code you have written here, and it is complaining about subscripts only being used for arrays. I have written an example of the code below. Can you see what i am doing wrong?

RETURNS LOGICAL
( input pcOriginator as char, /* from */
input pcRecipient as char, /* to */
input pcSubject as char,
input pcBody as char,
input pcAttachment as char ) :
/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/
define var lpMessage as memptr no-undo.
define var lpOriginator as memptr no-undo.
define var lpOrigDesc as memptr no-undo.
define var lpRecipient as memptr no-undo.
define var lpRecipDesc as memptr no-undo.
define var lpSubject as memptr no-undo.
define var lpBody as memptr no-undo.
define var lpFilePathName as memptr no-undo.
define var lpFileName as memptr no-undo.
define var lpFilePath as memptr no-undo.
define var lpFileDesc as memptr no-undo.
define var cFileName as char no-undo.
define var cFilePath as char no-undo.
define var iOffset as int no-undo.


/*------------------- Build Originator structure ----------------------------*/

assign
set-size(lpOriginator) = length(pcOriginator) + 1
put-string(lpOriginator,1) = pcOriginator
set-size(lpOrigDesc) = 25
put-long(lpOrigDesc,1) = 0 /* Reserved */
put-long(lpOrigDesc,5) = 0 /* Recip Class MAPI_ORIG */
put-long(lpOrigDesc,9) = get-pointer-value(lpOriginator) /* Names */
put-long(lpOrigDesc,13) = 0 /* Address */
put-long(lpOrigDesc,17) = 0 /* EID Size */
put-long(lpOrigDesc,21) = 0.

/*------------------- Build Recipient structure ----------------------------*/


/* -----Build Recipient details ----- */
SET-SIZE(lpRecipDesc) = (25 * NUM-ENTRIES(pcRecipient,";")).

DO ndx = 1 TO NUM-ENTRIES(pcRecipient,";"):
SET-SIZE(lpRecipient[ndx]) = LENGTH(ENTRY(ndx,pcRecipient,";")) + 1. /* maximum = 255 */
PUT-STRING(lpRecipient[ndx],1) = ENTRY(ndx,pcRecipient,";").
/* Recipient name */
PUT-LONG(lpRecipDesc,( 1 + ws-num-structs)) = 0. /* Reserved */
PUT-LONG(lpRecipDesc,( 5 + ws-num-structs)) = 1. /* RecipClass 1 = MAPI_TO */
PUT-LONG(lpRecipDesc,( 9 + ws-num-structs)) = GET-POINTER-VALUE(lpRecipient[ndx]).
/* Name */
PUT-LONG(lpRecipDesc,(13 + ws-num-structs)) = 0. /* Address */
PUT-LONG(lpRecipDesc,(17 + ws-num-structs)) = 0. /* EID Size */
PUT-LONG(lpRecipDesc,(21 + ws-num-structs)) = 0. /* Entry ID */

ASSIGN num-structs = num-structs + {&STRUCT-SIZE}.
END.


/*---------------------- Build Subject structure ----------------------------*/

assign
set-size(lpSubject) = length(pcSubject) + 1
put-string(lpSubject,1) = pcSubject.

/*------------------- Build Message Body structure --------------------------*/

assign
set-size(lpBody) = 16000
put-string(lpBody,1) = pcBody + (if pcAttachment = '':U then
'':U
else chr(10) + chr(10) + ' ':U).

/*------------------- Build Attachments structure ---------------------------*/

if pcAttachment <> "" then
do:
assign
cFileName = entry(num-entries(pcAttachment, '\':U),pcAttachment, '\':U)
cFilePath = replace(pcAttachment,cFilename,'':U)

/*----------------- Set the full path spec -----------------*/
set-size(lpFilePathName) = length(pcAttachment) + 1
put-string(lpFilePathName,1) = pcAttachment

/*----------------- Set the only file spec -----------------*/
set-size(lpFileName) = length(cFileName) + 1
put-string(lpFileName, 1) = cFileName

/*----------------- Set up attachment structure -----------------*/

set-size(lpFileDesc) = 25
put-long(lpFileDesc,1) = 0 /* reserved */
put-long(lpFileDesc,5) = 0 /* flags */
put-long(lpFileDesc,9) = length(pcBody) + 2 /* position */
put-long(lpFileDesc,13) = get-pointer-value(lpFilePathName)
put-long(lpFileDesc,17) = get-pointer-value(lpFileName)
put-long(lpFileDesc,21) = 0
.
end.

/*---------------------- Build Message structure ----------------------------*/

assign
SET-SIZE(lpMessage) = 45 + (NUM-ENTRIES(pcRecipient,";") * 4).
put-long(lpMessage,1) = 0 /* Reserved */
put-long(lpMessage,5) = get-pointer-value(lpSubject) /* subject */
put-long(lpMessage,9) = get-pointer-value(lpBody) /* body */
put-long(lpMessage,13) = 0 /* Message type */
put-long(lpMessage,17) = 0 /* Date Received */
put-long(lpMessage,21) = 0 /* ConversationId */
put-long(lpMessage,25) = 1 /* Flags */
put-long(lpMessage,29) = get-pointer-value(lpOrigDesc) /* Originator */
PUT-LONG(lpMessage,33) = NUM-ENTRIES(pcRecipient,";").
put-long(lpMessage,37) = get-pointer-value(lpRecipDesc) /* Recipient */
put-long(lpMessage,41) = (if pcAttachment = '':U then
0
else 1) /* Number of attachments */
put-long(lpMessage,45) = (if pcAttachment = '':U then
0
else get-pointer-value(lpFileDesc)).


/*---------------------------- Send Message now -----------------------------*/

run MAPISendMail(input 0, /* current session */
input 0, /* UIParam */
input lpMessage, /* pointer to message structure */
input 0, /* 11, /* flags, 1 = MAPI_LOGON_UI + 2 = MAPI_NEW_SESSION + 8 = MAPI_DIALOG */ */
input 0, /* reserved */
output iRetCode).

GetMapiError(iRetCode).

/*---------------------------- Deallocate memory ----------------------------*/

assign
set-size(lpMessage) = 0
set-size(lpOriginator) = 0
set-size(lpOrigDesc) = 0
set-size(lpRecipient) = 0
set-size(lpRecipDesc) = 0
set-size(lpSubject) = 0
set-size(lpBody) = 0
set-size(lpFilePathName) = 0
set-size(lpFileName) = 0
set-size(lpFileDesc) = 0
set-size(lpFilePath) = 0
.

RETURN FALSE. /* Function return value. */


I cannot see how the code can take into account the different class types for the recipients. Please help!! (N.B this code is work in progress)

Kind Regards,

Emma "This stuff is driving me :crazy: " McDonald.
 

Samj

Member
Emma

Try this:

define var lpRecipient as memptr extent 10 no-undo.

Don't forget to release memory for all the extents.

DO ndx = 1 TO 10:
SET-SIZE(lpRecipent[ndx]) = 0.
END.

And, did you define {&Struct-Size}?

Good luck,

Sam
 

Emma

Member
Re: Emma

Originally posted by Samj
Try this:

define var lpRecipient as memptr extent 10 no-undo.

Don't forget to release memory for all the extents.

DO ndx = 1 TO 10:
SET-SIZE(lpRecipent[ndx]) = 0.
END.

And, did you define {&Struct-Size}?

Good luck,

Sam

Hi again,

I had already included the {&Struct-Size}. I have also included the code you have written above. The program compile and ran. It did not send an email though, but did give the error message about an unknown recipient. I only tried to send the email to one person to test it initially. Any ideas?

Emma.
 

Samj

Member
Emma

I've tried it with 1 to 4 addresses. I'm using Netscape email and I do have to press the send button. To send automatically, change the forth param to 2.

RUN MAPISendMail IN hpApi(INPUT 0,
INPUT 0,
INPUT GET-POINTER-VALUE(MessageDescPtr),
INPUT 2,
/* 1 = MAPI_LOGON_UI + 2 = MAPI_NEW_SESSION + 8 = MAPI_DIALOG */
INPUT 0,
OUTPUT ResultInt).


You asked about different class types for the recipients earlier.

PUT-LONG(lpRecipDesc,( 5 + ws-num-structs)) = 1.
/* RecipClass 0 = MAPI_ORIG */
/* RecipClass 1 = MAPI_TO */
/* RecipClass 2 = MAPI_CC */
/* RecipClass 3 = MAPI_BCC */

Not sure about your invalid address error, double-check the value of your pcRecipient variable, the delimiter is a ';'.
 

Emma

Member
Re: Emma

Originally posted by Samj
I've tried it with 1 to 4 addresses. I'm using Netscape email and I do have to press the send button. To send automatically, change the forth param to 2.

RUN MAPISendMail IN hpApi(INPUT 0,
INPUT 0,
INPUT GET-POINTER-VALUE(MessageDescPtr),
INPUT 2,
/* 1 = MAPI_LOGON_UI + 2 = MAPI_NEW_SESSION + 8 = MAPI_DIALOG */
INPUT 0,
OUTPUT ResultInt).


You asked about different class types for the recipients earlier.

PUT-LONG(lpRecipDesc,( 5 + ws-num-structs)) = 1.
/* RecipClass 0 = MAPI_ORIG */
/* RecipClass 1 = MAPI_TO */
/* RecipClass 2 = MAPI_CC */
/* RecipClass 3 = MAPI_BCC */

Not sure about your invalid address error, double-check the value of your pcRecipient variable, the delimiter is a ';'.

i have altered the delimiter to ":" and pcRecipient is coming up as "McDonald, Emma;" which i thought would be right. it's still complaining though. If i change the sendmail 3rd parameter to INPUT GET-POINTER-VALUE(MessageDescPtr),
as with yours, it complains about a parameter format mismatch, even though it is defined as memptr. it compiles with just lpMessage. it's really getting me down now, but i can't see where it is going wrong.

Emma.
 

Samj

Member
Emma

Leave the SendMail variable lpMessage, that is how your memptr is defined.

I set the delimiter to ';' because someone else suggested it earlier. If you changed it to ':' then you need to make sure the references to NUM-ENTRIES also use ':' instead of ';' too.
 

Emma

Member
Re: Emma

Originally posted by Samj
Leave the SendMail variable lpMessage, that is how your memptr is defined.

I set the delimiter to ';' because someone else suggested it earlier. If you changed it to ':' then you need to make sure the references to NUM-ENTRIES also use ':' instead of ';' too.

That was my poor typing!! i have actually set it to ";", and have changed the variable back too, but still no success. I have sent you the code to have a look at. Good Luck !!
 
Top