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 24590 time(s), 3 post(s) 20.07.2011 14:36:33by inanc

Related topics

inanc

inanc

20.07.2011 14:36:33
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
Dieser Inhalt wurde noch nicht bewertet. 
469 Reputation 60 Total posts
denis

denis

20.07.2011 15:05:40
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);

Dieser Inhalt wurde noch nicht bewertet. 
7207 Reputation 956 Total posts
inanc

inanc

21.07.2011 06:02:16
Thank you for your answer.
Dieser Inhalt wurde noch nicht bewertet. 
469 Reputation 60 Total posts