I am trying to add a custom field to a Mail Message using the OLE Messaging
Library and Delphi 2.0. From my understanding I should be able to add this
custom field to the message, which is better than imbedding the info in the
message body, and the act upon that field.
I add the field to the message using the following code:.
8<-------------------- code starts
procedure TForm1.SendClick(Sender: TObject);
var loop : integer;
objField, objFieldCollection : variant;
begin
if loggedon then
begin
if not varISempty(objRecipientsCollection) then
begin
// Assign a object to objMessage
objMessage := objSession.Outbox.Messages.Add;
// Set the Message Subject
objMessage.Subject := edit2.text;
// Set the Message Text
objMessage.Text := memo1.text;
// Attach Recipients Object to Message
for loop := 1 to objRecipientsCollection.count do
begin
objRecipienttemp := objRecipientsCollection.item[loop];
objRecipient := objMessage.Recipients.Add;
objRecipient.name := objRecipienttemp.name;
objRecipient.type := objRecipienttemp.type;
objRecipient.Resolve;
end;
// Add some custom fields to the message
objFieldCollection := objMessage.Fields;
objField := objFieldCollection.Add(Name:='Caller',
class:=8, value:='Micahel Shuemacher'); {class 8 is a vbString}
// Update
objMessage.Update;
// Actually send the message to the recipients
objMessage.Send(showdialog:=false);
end
else showmessage('You do not have any mail recipients');
end
else showmessage('Cannot send message, you did not login.');
end;
8<-------------------- code ends
when trying to test if the field was actually sent with the message I have
used the following code:
8<-------------------- code starts
procedure TForm1.Button1Click(Sender: TObject);
var objMess, objMessCol, ObjFold, ObjFieldCol, objField : Variant;
begin
objFold := objSession.Inbox;
objMessCol := objFold.Messages;
objMess := objMessCol.GetFirst;
while not varISempty(objMess) do
begin
if not varISempty(objMess) then
begin
showmessage(objmess.subject);
objFieldCol := objMess.Fields;
showmessage(inttostr(objFieldCol.count));
end;
objMess := objMessCol.GetNext;
end;
end;
8<-------------------- code ends
When this code runs it reports that the message has 37 fields, is the
right?. Is this the correct way to add a field to a message, and if so how
do I access it?
ANY help GREATLY appreciated
Adam Keher
a...@sprint.com.au