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? (Zatvorena) (Mono Support )

24407 put(a) pogledan, 3 odgovor(a) 20.7.2011. 14:36:33Kreirao(la) inanc

Povezane teme

inanc

inanc

20.7.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
Ovaj sadržaj još nije ocijenjen. 
469 Reputacija 60 Ukupno objava
denis

denis

20.7.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);

Ovaj sadržaj još nije ocijenjen. 
7207 Reputacija 956 Ukupno objava
inanc

inanc

21.7.2011. 6:02:16
Thank you for your answer.
Ovaj sadržaj još nije ocijenjen. 
469 Reputacija 60 Ukupno objava