PROBLEM A)
The code that fails A), is at the bottom in this email. newAppt.Send.
I have in fact already studied the MsgStoreAppointments example,
but it is of cause possible that I have missed something.
The problem is that the sample application seems to fail in the exact
same way as my function. Running it, I log on, invite a contact, and
pressing send. The result is access violation, exactly like in my
program. Here is a copy of your example code that fails with access
violations:
procedure TFrmAppointment.actSendExecute(Sender: TObject);
begin
inherited;
SetMessageProps;
(Msg as IRwMapiAppointment).Send; //Fails, access violation.
Close;
end;
PROBLEM B)
New comment. I have observed that my function (at the bottom of this
email), did not set the PR_SENDER.. properties properly. Is that
required? How does MAPI pick up the sender? The code below should
pick the organizer, but it is nothing there...
NewAppt.Body := 'Organisator:'+NewAppt.Organizer+SLineBreak+
'Mottagere:'+Recipients; //for debug
Yesterday I added the following code before that line (just for testing):
NewAppt.PropByName(PR_SENDER_EMAIL_ADDRESS).AsString
NewAppt.PropByName(PR_SENDER_NAME).AsString :='Hans Reier
Sigmond';
PR_SENDER_NAME seems to be the same as organizer. But the attribute
PR_SENDER_ENTRYID is still without a value. Should it be set (by the
system or by the programmer)?.
Can a misssing PR_SENDER_ENTRYID cause other errors?
PROBLEM C)
I will look at the example before eventually adding more comments.
What I do see is that my current code does this completely wrong in many
cases.
Reier (I usually use my middle name and not the first one)
> Hi Hans,
>
> I recommend you take a look a the MsgStoreAppointments example
> application (intermediate examples directory). This application
> demonstrates how to create appointments and how to send meeting
> requests.
>
>
>> PROBLEM A) NewAppt.Send. This works OK for a new appointment
>> When I try to open an existing appointment by EntryId,
>> I always get access violation.
>
> It sounds like the problem is in the code that opens the appointment.
> Do you have a code snippet of that code?
>
>
>> PROBLEM B) I have observed that the organizer is not stored in the
>> recipient table. Should it be?
>
> No. The organizer is retrieved from the person who creates the
> appointment.
>
>
>> PROBLEM C) NewAppt.SaveChanges. In most of the cases the changes are
>
> It looks like you have a name resolve issue.
> I recommend you take a look at the AddrBookNameResolving.dpr example
> application (in the basic examples folder) to see what Name resolving
> is and how it work.
>
> Regards,
>
> Peter.
>
>
>
> Hans Reier Sigmond wrote:
>
>> I have written a small Delphi function that can add a new appointment
>> and update the same apointment. There are several problems with this
>> routine that I so far are unable to solve. I suspect that it is my
>> understanding of MAPI that is not good enough to solve this.
>>
>> To your information: We are currently not using an exchange server,
>> can this cause problems? We are going to do this, but have not
>> installed it yet.
>>
>> PROBLEM A) NewAppt.Send. This works OK for a new appointment. When I
>> try to open an existing appointment by EntryId, I always get access
>> violation.I have tried to display the various access rights set for
>> folders and appointments (MAPI parameters), but I cannot figure out
>> anything wrong. I suspect this is a MAPI issue. I have also tries to
>> set various MAPI parameters, but with no success so far. Has anyone
>> got an idea of what the problem can be?
>>
>> PROBLEM B) I have observed that the organizer is not stored in the
>> recipient table. Should it be? The name of the organizer is empty.
>> Can this small problem be connected with PROBLEM A). I am still able
>> to define a new appointment, invite recipients and the result appears
>> in outlook, but the name of the organizer is empty. Where does MAPI
>> fetch this information?
>>
>> PROBLEM C) NewAppt.SaveChanges. In most of the cases the changes are
>> saved as expected, but not always. The recipient list is e.g. entered
>> like this: Hans Reier Sigmond; Per Arne Trillerud; ..., all the names
>> separated by semicolons in the Recipients string. The AddRecipients
>> method looks in the Outlook contacts and other places in Outlook and
>> will map these names into email address if it can find it.
>>
>> When the NewAppt.SaveChanges are run, a popup dialog appears and I am
>> able to select from the contact list if the receipient is not found.
>> Fine so far... But when I e.g. look at the created appointment,
>> outlook in many cases mixes up the email adresses (e.g. picks the
>> email address of Per Arne Trillerud and not mine). But it is not only
>> the email address that get mixed up, sometimes it also picks the
>> wrong recipient and displays in outlook. And I am unable to correct
>> this manually since it is the automatic mapping that is wrong, and
>> not the one where I am asked to search for the appropriate contact.
>>
>> best regards from Hans Reier Sigmond
>>
>> I am currently evaluating easyMapi. Problem C) is for our company
>> quite serious, since the response is unpredictable.
>>
>> (Search in the below code for "PROBLEM .." where the problems occurs).
>>
>> Here us the code:
>>
>> function TOutlookForm.CreateAppointment(Subject, Location: String;
>> Start, Finish: TDateTime; Recipients: string; EntryId:
>> TRwMapiEntryId): TRwMapiEntryId; var
>> NewAppt: IRwMapiAppointment;
>> Invited: IRwMapiRecipientTable;
>> MsgStore: IRwMapiMsgStore;
>> Organizer : TRwMapiEntryId;
>> begin
>> try
>> try
>> // MapiSession.LogonInfo.ProfileName := '';
>> MapiSession.LogonInfo.ProfileRequired := False; //No logon
>> dialog is shown MapiSession.LogonInfo.ShowLogonDialog := True;
>> //Why this? //MapiSession.LogonInfo.ShowPasswordDialog := true;
>>
>> MapiSession.LogonInfo.UseExtendedMapi := True;
>> MapiSession.Active := false;
>>
>> if not(MapiSession).Active then
>> begin
>> MapiSession.Logon; //Eventually show logon dialog, log on!
>> end;
>>
>> if (EntryId <>null) then
>> begin
>> ShowMessage('Åpner eksisterende avtale');
>> MsgStore := MapiSession.OpenDefaultMsgStore;
>> NewAppt := MsgStore.OpenMessage(EntryId) as
>> IrwMapiAppointment; //NewAppt.DisplayProperties;
>> NewAppt.Recipients.DisplayFields;
>> end else
>> begin
>> NewAppt := MapiSession.CreateMessage(ftAppointment) as
>> IRwMapiAppointment;
>> NewAppt.Recipients.AddRecipients(Recipients, rtTo, true); end;
>>
>>
>> NewAppt.Subject := Subject;
>> NewAppt.Location := Location;
>> NewAppt.SetDateRange(false, Start, Finish, true );
>> NewAppt.ReminderMinutesBeforeStart := 15;
>> NewAppt.ReminderSet := true;
>> NewAppt.BusyStatus := 0;
>> NewAppt.Body := ''; //No comments, not allowed
>> NewAppt.Body := 'Organisator:'+NewAppt.Organizer+SLineBreak+
>> 'Mottagere:'+Recipients; //for debug PROBLEM
>> B) NewAppt.IsPrivate := false;
>> NewAppt.PropByName(NPR_SEND_INVITATIONS_AND_UPDATES).AsBoolean
>> := true; NewAppt.Categories := 'Rusdata';
>>
>> NewAppt.SaveChanges(smKeepOpenReadWrite); //PROBLEM C)
>> NewAppt.MeetingRequestSent := false;
>>
>> NewAppt.Send; //Send to recipients PROBLEM A
>> Result := NewAppt.EntryID;
>> except
>> on E: EOleException do ;
>> else raise;
>> end;
>> finally
>> MapiSession.Logoff;
>> MapiSession.Active := false;
>> end;
>> end;
>
>
>