Highlighted
Frequent Contributor.
Frequent Contributor.
87 views

Avoiding infinite loop when handling command (C3PO)

Jump to solution

I am trying to write a c3po to check for missing email attachments before a user sends an email.

 

I am using the following code:

vCommander := CreateOleObject('GroupWiseCommander');
vCommander.Execute(AnsiString('ItemMessageIDFromView()'),
myMessageID);
vCommander.Execute(AnsiString('ItemGetText("' + myMessageID +
'";Message!)'), sResult);

AttachmentSuggested := EmailBodySuggestsAttachment(sResult);

// if AttachmentsCDS.isempty then
begin
if AttachmentSuggested <> '' then
MessageDlg('Did you mean to attach files?' + chr(13) +
'You wrote ''' + AttachmentSuggested +
''' in your message, but there are no files attached. Send anyway?',
mtConfirmation, [mbYes, mbNo], 0);
end;

// g_C3POManager.ClientState.CommandMessage.send;
vCommander.Execute(AnsiString('ItemSend()'), sResult);
vCommander := Unassigned;

The problem that I am encountering is that when my code tries to invoke the itemsend command, it reinvokes my code recursively.  How can I actually send the email?  Second question, my message id for this email will almost always be "X00" for a new message.  If the user has multiple new email messages opened, how can I be sure that the correct email is being sent?

Labels (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

You need to do something like:

this->BaseCommand->Execute();

to continue the send.

X00 refers to the current active view. This should correspond to the item currently being sent.

View solution in original post

0 Likes
4 Replies
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

You need to do something like:

this->BaseCommand->Execute();

to continue the send.

X00 refers to the current active view. This should correspond to the item currently being sent.

View solution in original post

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Thank you.  What do I do to stop the email from sending?

0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

By not calling the base command, the send operation should be cancelled

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Thank you (again).  That worked.  That was what I was initially trying but it was throwing an error for some reason/ now it fully works.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.