Dotnet var Outlook Application

AvallackAvallack Member Posts: 18
edited 2013-03-26 in NAV Three Tier
Hi all,

I would like consume a interop outlook variable to read my mails from Navision 2013 any success...

Name DataType Length Subtype
Application DotNet Microsoft.Office.Interop.Outlook.Application.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
NameSpace DotNet Microsoft.Office.Interop.Outlook._NameSpace.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

Code :

Application := Application;
NameSpace := Application.GetNamespace('MAPI');


This code give me an error .. "Application is not instantiate" , i dont understand where is my error because from a console application, it's work! :(

Thank for your help.
Navision Technical Consultant & .Net Developer

Comments

  • AvallackAvallack Member Posts: 18
    solved, thx.
    Navision Technical Consultant & .Net Developer
  • Danny69Danny69 Member Posts: 1
    HI...

    how do you solved the problem?
    I have the same one.

    I try do use .Net
    Microsoft.Office.Interop.Outlook.Application.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
    for creating Appointments with RTC.

    I already tried to use the AppointmentClass for creating the Object, but still not working.

    olItemType := olItemType.olAppointmentItem;
    oAppClass := oAppClass.ApplicationClass();

    IF ISNULL(outlookApp) THEN BEGIN
    outlookApp := oAppClass;
    END;
    oAppointment := oAppointment;

    oAppointment := outlookApp.CreateItem(olItemType);
    oAppointment.Subject := 'This is the subject for my appointment';
    oAppointment.Body := 'This is the body text for my appointment';
    oAppointment.Location := 'Appointment location';
    // Set the start date
    oAppointment.Start := CREATEDATETIME(101013D,100000T);
    // End date
    oAppointment."End" := CREATEDATETIME(101013D,120000T);
    // 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();

    oMailItem := oAppointment.ForwardAsVcal();
    oMailItem."To" := 'xxx'
    oMailItem.Send();

    Any idears?
  • AvallackAvallack Member Posts: 18
    I'm trying your code, on my side, it's worked. I think your turn on "runonclient" property and instantiate correctly your variable. There are some mistake or confusion between interface and class.

    Below the code who worked :

    Name DataType Subtype Length
    outlookApp DotNet Microsoft.Office.Interop.Outlook.Application.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
    oAppClass DotNet Microsoft.Office.Interop.Outlook.ApplicationClass.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
    oAppointment DotNet Microsoft.Office.Interop.Outlook.AppointmentItem.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
    oAppointmentClass DotNet Microsoft.Office.Interop.Outlook.AppointmentItemClass.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
    olItemType DotNet Microsoft.Office.Interop.Outlook.OlItemType.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
    oMailItem DotNet Microsoft.Office.Interop.Outlook.MailItem.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'


    olItemType := olItemType.olAppointmentItem;

    outlookApp := oAppClass.ApplicationClass();
    oAppointment := oAppointmentClass;

    oAppointment := outlookApp.CreateItem(olItemType);
    oAppointment.Subject := 'This is the subject for my appointment';
    oAppointment.Body := 'This is the body text for my appointment';
    oAppointment.Location := 'Appointment location';
    // Set the start date
    oAppointment.Start := CREATEDATETIME(101013D,100000T);
    // End date
    oAppointment."End" := CREATEDATETIME(101013D,120000T);
    // 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();

    oMailItem := oAppointment.ForwardAsVcal();
    oMailItem."To" := 'To mail';
    oMailItem.Send();
    Navision Technical Consultant & .Net Developer
Sign In or Register to comment.