Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Creating email alerts from the code

(0) ShareShare
ReportReport
Posted on by 10

Hi everyone,

First of all, let me say that I am very new to Dynamics Ax so sorry if this is a stupid question.

So my problem is that I need to setup an email alert when an activity of type "Appointment" is created. The alert should be triggered 1 hour before the appointment is due. I'm not quite sure how to do this as we are not integrating Dynamics with Outlook.

So here is what I managed to do so far:

- I made sure that the "E-mail distributor batch" process was running. To be sure of that I've set an email alert on it to be send when the process has finished. It worked fine and I was receiving emails and pop-ups.

- I manage to somehow create an alert from the code, using something along these lines:

 inboxId = EventInbox::nextEventId();

    inbox.initValue();
    inbox.ShowPopup = NoYes::Yes;
    inbox.Subject = "The new activity has been created";
    inbox.Message = "Don't forget about it please.";
    inbox.SendEmail = true;
    inbox.UserId = curUserID();
    inbox.AlertTableId = 2271;
    inbox.ParentTableId = 2271;
    inbox.AlertedFor = "Event: Activity updated";
    inbox.EmailRecipient = myEmail@myDomain.com;
    inbox.TypeId = classnum(eventTypeDue);
    inbox.TypeTrigger = EventTypeTrigger::DueType;

    inbox.InboxId = inboxId;

    inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();

    inbox.insert();

The code above is creating the alert and I'm getting the popup.

My problem is that in this case the email is not sent...

Also, in this case the alert is sent straight away and I haven't really found a way to delay it to be send at the time I want.

And that's it, I'm stuck there. Does anyone have a solution to my problem?

Also, I had a look at the activities of type "Reminder" but those ones are valid only when integrating with Outlook right?

 Thanks for your help.

Regards

 

*This post is locked for comments

  • Fabien Ruffin Profile Picture
    Fabien Ruffin 10 on at
    Re: Creating email alerts from the code

    By the way, I forgot to mention that this alert should apply to all users. What I mean is that by default, all users should automatically receive an email reminding them of the appointment activity they create.

     Thanks

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans