Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

sending outlook meeting request through x++ code

Posted on by 30

I am having following code which creates the outlook appointment in my calendar but does not send to recipients. I want to send it to recipients.

static void OutlookAppointment(Args _args)

{

COM    sysOutlookCollection;
   COM    receipiants;
   COM    collection;
   COMVariant comStartDate = new COMVariant();
   COMVariant comEndDate  = new
   COMVariant();
   COM    c;
   #SysOutLookCOMDEF
   #define.mapi("MAPI")
   #define.outlook("Outlook.Application")
   COM    sysOutlook;
   COM    sysOutlookNameSpace;
   COM    sysOutlookMAPIFolder;








    ;


 sysOutlook         = new COM(#outlook);


sysOutlookNameSpace         = sysOutlook.getNamespace(#mapi);


sysOutlookNameSpace.logon();


sysOutlookMAPIFolder        =
sysOutlookNameSpace.getDefaultFolder(#OlDefaultFolders_olFolderCalendar);
   //sysOutlookNameSpace.getDefaultFolder(#OlDefaultFolders_olFolderOutbox);


collection=sysOutlookMAPIFolder.items();

    c =collection.add();


comStartDate.date(today());


comStartDate.time(str2Time( "16:00:00"));


comEndDate.date(today());


comEndDate.time(str2Time( "16:45:00"));


c.location("dotcom");


c.subject("Ax testing");


c.body("Ax testing");


c.start(comStartDate);


c.end(comEndDate);


c.save();

    if (c)

    {

       receipiants = c.Recipients();
    receipiants.add("xyz@xyz.com");
     
     receipiants.ResolveAll();
    
        
    
        //c.finalize();

    // c.assign();
     
     c.display();
       // c.sendtoreceipiants();
     c.send();
      
   
     // collection.send();

         c.finalize();




info("The action is created in Microsoft Outlook");

    }

    else


throw error("@SYS31969");


sysOutlookNameSpace.logoff();

}

*This post is locked for comments

  • UmesH@ Profile Picture
    UmesH@ 810 on at
    RE: sending outlook meeting request through x++ code

    Hi Mukesh04 When you Insert Code Give it some Design.

    static void OutlookAppointment(Args _args)
    {
       COM    sysOutlookCollection;
       COM    receipiants;
       COM    collection;
       COMVariant comStartDate = new COMVariant();
       COMVariant comEndDate  = new
       COMVariant();
       COM    c;
       #SysOutLookCOMDEF
       #define.mapi("MAPI")
       #define.outlook("Outlook.Application")
       COM    sysOutlook;
       COM    sysOutlookNameSpace;
       COM    sysOutlookMAPIFolder;
        ;
       sysOutlook         = new COM(#outlook);
       sysOutlookNameSpace         = sysOutlook.getNamespace(#mapi);
       sysOutlookNameSpace.logon();
       sysOutlookMAPIFolder        =
       sysOutlookNameSpace.getDefaultFolder(#OlDefaultFolders_olFolderCalendar);
       //sysOutlookNameSpace.getDefaultFolder(#OlDefaultFolders_olFolderOutbox);
       collection=sysOutlookMAPIFolder.items();
       c =collection.add();
       comStartDate.date(today());
       comStartDate.time(str2Time( "16:00:00"));
       comEndDate.date(today());
       comEndDate.time(str2Time( "16:45:00"));
       c.location("dotcom");
       c.subject("Ax testing");
       c.body("Ax testing");
       c.start(comStartDate);
       c.end(comEndDate);
       c.save();
       if (c)
       {
           receipiants = c.Recipients();
           receipiants.add("xyz@xyz.com");     
           receipiants.ResolveAll(); 
           //c.finalize();
           // c.assign();     
           c.display();
           // c.sendtoreceipiants();
           c.send();    
           // collection.send();
           c.finalize();
           info("The action is created in Microsoft Outlook");
        }
        else
           throw error("@SYS31969");
           sysOutlookNameSpace.logoff();
    }


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,228 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans