Creating a new message

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

The following sample code shows how you can create a new message, edit its text and finally delete it, all using the API.




using CMS.Messaging;

using CMS.CMSHelper;

using CMS.SiteProvider;

using CMS.GlobalHelper;




        // Creates a new message from CurrentUser to administrator

        MessageInfo message = new MessageInfo();

        message.MessageSubject = "Subject";

        message.MessageBody = "Hello world!";

        message.MessageSenderUserID = CMSContext.CurrentUser.UserID;

        message.MessageRecipientUserID = UserInfoProvider.GetUserInfo("administrator").UserID;

        message.MessageSent = DateTime.Now;



        // Gets the previously created message and edits its body

        MessageInfo messageToEdit = MessageInfoProvider.GetMessageInfo(message.MessageID);

        messageToEdit.MessageBody += " This message was edited";




        // Deletes the previously created and edited message



Page url: