Hi all,
I have been lurking these forums for a long time and you guys have helped me overcome a lot of issues we were facing, but I did not find anything related to what I am going write next.
I have created a codeunit which you can call from various tables to create Outlook Appointments.
However the Time of the Appointment Item.Start attribute always defaults to midnight (00:00). As a result I cannot really create Appointments automatically for them and I have to pop up the Calendar Window so that they can manually select the time.
Please note this happens only when the Codeunit is called from the RTC Client. If we use the Classic the time is set correctly.
Please find the code below.
IF NOT CREATE(Application,FALSE,TRUE) THEN
EXIT;
char13 :=13;
char10:=10;
//text:= text1 +format(char13)+format(char10)+ text2;
Namespace := Application.GetNamespace('MAPI');
Namespace.Logon;
"Appointment Item" := Application.CreateItem(1);
"Appointment Item".Start(DATI2VARIANT(date,120000T));
"Appointment Item".Subject := Type+ ' - ' + Name+' - ' +"Name 2";
"Appointment Item".Body := 'This is an automated appointment sent from NAV.'+FORMAT(char13) + FORMAT(char10) +
'Phone number(s): ' + "Phone No." + ' . ' + "Mobile Phone No.";
"Appointment Item".Duration := 60;
"Appointment Item".ReminderMinutesBeforeStart := 1;
"Appointment Item".ReminderSet := TRUE;
"Appointment Item".Location := 'Phone';
"Appointment Item".Display;
//"Appointment Item".Save;
Namespace.Logoff;
CLEAR(Application);
As you can see I commented off the "Save" and replaced it with "Display" in order for the window to pop up.
Any kind of input will be appreciated!
I apologise in advance if something is not clear, English is not my first language.
Regards
Constantine
0
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Thank you for helping!
When I looked into Codeunit 5073 from NAV 4, I see>
It means it should work. Try first to add this before you set the Start...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Ah well, I ll try to redo the whole thing but with using DotNet variables instead of Automation variables.
Lets see how that will go.
This is the code I used:
outlookApp := oAppClass.ApplicationClass();
oAppointment := oAppointmentClass;
oAppointment := outlookApp.CreateItem(1);
oAppointment.Subject := Subject;
oAppointment.Body := Body;
//oAppointment.Location := 'Appointment location';
// Set the start date
oAppointment.Start := CREATEDATETIME(StartDate,StartTime);
// End date
oAppointment."End" := CREATEDATETIME(StartDate,EndTime);
// Set the reminder 15 minutes before start
oAppointment.ReminderSet := TRUE;
oAppointment.ReminderMinutesBeforeStart := 15;
//Setting the sound file for a reminder:
oAppointment.ReminderPlaySound := TRUE;
//set ReminderSoundFile to a filename.
//Setting the importance:
//use OlImportance enum to set the importance to low, medium or high
//oAppointment.Importance := Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
//oAppointment.BusyStatus := Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;;
//oAppointment.Save();
oAppointment.Display(oAppointment);
Parameters:
Var Name DataType Subtype Length
No Subject Text 1000
No Body Text 1000
No StartTime Time
No EndTime Time
No StartDate Date
No location Text 1000
Variables:
Name DataType Subtype Length
outlookApp DotNet 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.Application
oAppClass DotNet 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.ApplicationClass
oAppointment DotNet 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.AppointmentItem
oAppointmentClass DotNet 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.AppointmentItemClass
olItemType DotNet 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.OlItemType
oMailItem DotNet 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.MailItem
not sure if you already solved the problem, and how urgent this is for your customer, but we had the same kind of problems before. Things not working properly in the integration, no debugging possible, and not flexible.
We have created a new NAV-Outlook Synchronisationautomation where you, as a developper, can make changes very easy.
Perhaps this could be interesting for you.
See our website http://www.vssolutions.nl
If you still have this issue, and your customer wants you to fix it: here's your solution
Ernst
Did you get this to work setting the start time and end time of an outlook meeting?
I have tried using your method with a dotnet variable and even though in NAV it has the correct time e.g. StartTime = 1600T when the actual meeting is created it seems to read the time incorrectly and creates a meeting at 0600 AM
I have tried also changing my regional date and time settings on the computer/server so that they are all in 24 hour format as well but still no difference.
Changed the call to this and it worked!
oAppointment.StartUTC := CREATEDATETIME(StartDate,StartTime);
oAppointment.EndUTC := CREATEDATETIME(StartDate,EndTime);