MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

How can I send a private message programmatically? (Closed) (Mono Support )

Viewed 23344 time(s), 3 post(s) 7/20/2011 2:36:33 PMby inanc

Related topics

inanc

inanc

7/20/2011 2:36:33 PM
Hello,
How can I send a private message programmatically? Can you give an example please?

I am trying to use the method

public virtual bool SendMessageToUser(
Guid messageId,
Guid userId,
MessageStatus status,
bool sendMailCopy
)

But no use.
Thank you.
Inanc
This content has not been rated yet. 
469 Reputation 60 Total posts
denis

denis

7/20/2011 3:05:40 PM
Hi Inanc,
Message sending is actually a two step process if you are going to use the MessageRepository: first you need to create and store the actual message, and after that you are going to use the method you discovered to pass the message to the intended recipients.
The code would look like this:

var messageRep = MonoSoftware.MonoX.Repositories.MessageRepository.GetInstance();
Guid messageId = GuidExtension.NewSequentialGuid();
//create and store the message
SnMessageEntity message = messageRep.SaveMessage(SecurityUtility.GetUserId(), messageId, "Hello message", "Message text body", Guid.Empty, UserName);
//pass the message to the initial recipient - not that you may have multiple recipeints in some scenarios, so you can send the message to all of them by calling this method in a loop. this.UserId is the ID of the user that should receive the message (in this case it is a property of the Web part from which this code was taked from), please modify it to fit your scenario.
messageRep.SendMessageToUser(messageId, this.UserId, MessageStatus.Received, false);
//save the message in the "sent messages" folder of the currently active user.
messageRep.SendMessageToUser(messageId, SecurityUtility.GetUserId(), MessageStatus.Sent, false);

This content has not been rated yet. 
7207 Reputation 956 Total posts
inanc

inanc

7/21/2011 6:02:16 AM
Thank you for your answer.
This content has not been rated yet. 
469 Reputation 60 Total posts