Hallo forum
I need advice on how to retrieve mail from an GW Mailbox. I managed to
send a mail with attachment but can't get the attachment back on the
other side.

I have looked over numerous examples from the Novell Web page but can't
figure out how to solve my problem.

Here is my basic code hoping someone could look over it giving me a
pointer in the right direction, any help is highly appreciated.


var v_MsgIter:variant;
v_Msg:variant;
vAccount:variant;
vRootAccount:variant;

// login part
vAccount := CreateOleObject('NovellGroupWareSession');
vRootAccount := vAccount.Login(vusername,vpassword);

//Get AllMessages object -> Contains all messages in an account.
vAllMsgs:=vRootAccount.AllMessages;

//Create Message iterator
v_MsgIter:=vAllMsgs.CreateAllMessagesIterator;

//Get first message
v_Msg:=v_MsgIter.Next;

While((NOT varisNull(v_Msg)) AND (NOT varisEmpty(v_Msg))) do begin

//Add Msg.Subject to listbox1
ListBox1.Items.Add(v_Msg.Subject);
ListBox1.Update;

//Save MessageID in non-displayed listbox2
ListBox2.Items.Add(v_Msg.MessageID);
ListBox2.Update;

//Get next message ->Returns the next message in the collection
or nothing after the last message.
v_Msg:=v_MsgIter.Next;

// end login

//================================================== ==================================================//

// Click on listbox1 triggers GetItemData

procedure GetItemData
var
MsgID:string;
tempstr:string;
Msg:variant;
BoxType:variant;
AI:integer;
begin

Memo1.Clear; //Clear memo control
ListBox3.Items.Clear;

//Get message ID from ListBox2
MsgID:=ListBox2.Items[ListBox1.ItemIndex];

//Get MessageObject
Msg:=vRootAccount.GetMessage(MsgID);

//Display FromText property
tempstr:='From: '+Msg.FromText;
Memo1.Lines.Add(tempstr);

//Display creation date
tempstr:='Date: '+DatetoStr(Msg.CreationDate);
Memo1.Lines.Add(tempstr);

//Display Message box type (inbox,outbox, etc);
BoxType:=Msg.BoxType;
Case BoxType of
1:Memo1.Lines.Add('BoxType: Inbox');
2:Memo1.Lines.Add('BoxType: OutBox');
3:Memo1.Lines.Add('BoxType: Personal');
4:Memo1.Lines.Add('BoxType: Draft');
else
Memo1.Lines.Add('BoxType: ');
end;

//Display message class
tempstr:='ClassName: '+Msg.ClassName;
Memo1.Lines.Add(tempstr);

//Display Subject
tempstr:='Subject: '+Msg.Subject.PlainText;
Memo1.Lines.Add(tempstr);

//Separate Message text from other data
Memo1.Lines.Add('');
Memo1.Lines.Add('------- Message -------');
Memo1.Lines.Add(Msg.BodyText.PlainText);

if Msg.Attachments.Count>0 then begin
ListBox3.Items.Add('');
ListBox3.Items.Add('--- Attachments ---');
for AI := 1 to Msg.Attachments.Count do
ListBox3.Items.Add(Format('%s (%s)',
[Msg.Attachments.Item(AI).FileName,
Msg.Attachments.Item(AI).DisplayName]));
end;
end;


// Save attachment procedure
procedure SaveAttach;
var Msg:variant;
MsgID:string;
SaveName:string;
begin
//Get Message ID from ListBox2
MsgID:=ListBox2.Items[ListBox1.ItemIndex];

//Get Message Object then delete object
Msg:=vRootAccount.GetMessage(MsgID);

if Msg.Attachments.Count>0 then begin
SaveName:=Format('%s',[Msg.Attachments.Item(1).FileName]);
Msg.Save(PathWhereToSaveAttachment\'+SaveName);
end;
end;