Message
type.MsgSendMessage
API (details) is the core API for sending a message. It supports sending all types of messages.Type | Name | Description |
System.String | conv_id | Conversation ID |
TIMConvType | conv_type | Conversation type |
Message | message | Message |
System.Text.StringBuilder | message_id | Message ID |
ValueCallback | ValueCallback | callback | Async callback |
public static void MsgSendMessage() {string conv_id = ""; // The conversation ID of a one-to-one message is the `userID`, and that of a group message is the `groupID`.Message message = new Message{message_conv_id = conv_id,message_conv_type = TIMConvType.kTIMConv_C2C, // For a group message, this value is `TIMConvType.kTIMConv_Group`message_elem_array = new List<Elem>{new Elem{elem_type = TIMElemType.kTIMElem_Text,text_elem_content = "This is an ordinary text message"}}};StringBuilder messageId = new StringBuilder(128);TIMResult res = TencentIMSDK.MsgSendMessage(conv_id, TIMConvType.kTIMConv_C2C, message, messageId, (int code, string desc, string json_param, string user_data)=>{// Async message sending result});// The message ID messageId returned when the message is sent}
public static void MsgSendMessage() {string conv_id = ""; // The conversation ID of a one-to-one message is the `userID`, and that of a group message is the `groupID`.Message message = new Message{message_conv_id = conv_id,message_conv_type = TIMConvType.kTIMConv_C2C, // For a group message, this value is `TIMConvType.kTIMConv_Group`message_elem_array = new List<Elem>{new Elem{elem_type = TIMElemType.kTIMElem_Image,image_elem_orig_path = "/Users/xxx/xxx.png", // Absolute path to the fileimage_elem_level = TIMImageLevel.kTIMImageLevel_Orig // Send an original image}}};StringBuilder messageId = new StringBuilder(128);TIMResult res = TencentIMSDK.MsgSendMessage(conv_id, TIMConvType.kTIMConv_C2C, message, messageId, (int code, string desc, string json_param, string user_data)=>{// Async message sending result});// The message ID messageId returned when the message is sent}
public static void MsgSendMessage() {string conv_id = ""; // The conversation ID of a one-to-one message is the `userID`, and that of a group message is the `groupID`.Message message = new Message{message_conv_id = conv_id,message_conv_type = TIMConvType.kTIMConv_C2C, // For a group message, this value is `TIMConvType.kTIMConv_Group`message_elem_array = new List<Elem>{new Elem{elem_type = TIMElemType.kTIMElem_Sound,sound_elem_file_path = "/Users/xxx/xxx.mp3", // Absolute file pathsound_elem_file_size = 10 // Audio duration}}};StringBuilder messageId = new StringBuilder(128);TIMResult res = TencentIMSDK.MsgSendMessage(conv_id, TIMConvType.kTIMConv_C2C, message, messageId, (int code, string desc, string json_param, string user_data)=>{// Async message sending result});// The message ID messageId returned when the message is sent}
public static void MsgSendMessage() {string conv_id = ""; // The conversation ID of a one-to-one message is the `userID`, and that of a group message is the `groupID`.Message message = new Message{message_conv_id = conv_id,message_conv_type = TIMConvType.kTIMConv_C2C, // For a group message, this value is `TIMConvType.kTIMConv_Group`message_elem_array = new List<Elem>{new Elem{elem_type = TIMElemType.kTIMElem_Video,video_elem_video_path = "/Users/xxx/xxx.mp4", // Absolute file pathvideo_elem_video_type = "mp4", // Video typevideo_elem_video_duration = 10, // Video durationvideo_elem_image_path = "Absolute path of the local video thumbnail file",video_elem_image_type = "png", // Type of the video screenshot filevideo_elem_image_size = 100, // Size of the video screenshot filevideo_elem_image_width = 1920, // Width of the video screenshot filevideo_elem_image_height = 1080, // Height of the video screenshot file}}};StringBuilder messageId = new StringBuilder(128);TIMResult res = TencentIMSDK.MsgSendMessage(conv_id, TIMConvType.kTIMConv_C2C, message, messageId, (int code, string desc, string json_param, string user_data)=>{// Async message sending result});// The message ID messageId returned when the message is sent}
public static void MsgSendMessage() {string conv_id = ""; // The conversation ID of a one-to-one message is the `userID`, and that of a group message is the `groupID`.Message message = new Message{message_conv_id = conv_id,message_conv_type = TIMConvType.kTIMConv_C2C, // For a group message, this value is `TIMConvType.kTIMConv_Group`message_elem_array = new List<Elem>{new Elem{elem_type = TIMElemType.kTIMElem_File,file_elem_file_path = "/Users/xxx/xxx.x", // Absolute file pathfile_elem_file_name = "Filename",}}};StringBuilder messageId = new StringBuilder(128);TIMResult res = TencentIMSDK.MsgSendMessage(conv_id, TIMConvType.kTIMConv_C2C, message, messageId, (int code, string desc, string json_param, string user_data)=>{// Async message sending result});// The message ID messageId returned when the message is sent}
public static void MsgSendMessage() {string conv_id = ""; // The conversation ID of a one-to-one message is the `userID`, and that of a group message is the `groupID`.Message message = new Message{message_conv_id = conv_id,message_conv_type = TIMConvType.kTIMConv_C2C, // For a group message, this value is `TIMConvType.kTIMConv_Group`message_elem_array = new List<Elem>{new Elem{elem_type = TIMElemType.kTIMElem_Location,location_elem_desc = "Shennan Boulevard, Nanshan District, Shenzhen",// Location information digestlocation_elem_longitude = 34, // Longitudelocation_elem_latitude = 20 // Latitude}}};StringBuilder messageId = new StringBuilder(128);TIMResult res = TencentIMSDK.MsgSendMessage(conv_id, TIMConvType.kTIMConv_C2C, message, messageId, (int code, string desc, string json_param, string user_data)=>{// Async message sending result});// The message ID messageId returned when the message is sent}
public static void MsgSendMessage() {string conv_id = ""; // The conversation ID of a one-to-one message is the `userID`, and that of a group message is the `groupID`.Message message = new Message{message_conv_id = conv_id,message_conv_type = TIMConvType.kTIMConv_C2C, // For a group message, this value is `TIMConvType.kTIMConv_Group`message_elem_array = new List<Elem>{new Elem{elem_type = TIMElemType.kTIMElem_Face,face_elem_index = 0,face_elem_buf = ""}}};StringBuilder messageId = new StringBuilder(128);TIMResult res = TencentIMSDK.MsgSendMessage(conv_id, TIMConvType.kTIMConv_C2C, message, messageId, (int code, string desc, string json_param, string user_data)=>{// Async message sending result});// The message ID messageId returned when the message is sent}
public static void MsgSendMessage() {string conv_id = ""; // The conversation ID of a one-to-one message is the `userID`, and that of a group message is the `groupID`.Message message = new Message{message_conv_id = conv_id,message_conv_type = TIMConvType.kTIMConv_C2C, // For a group message, this value is `TIMConvType.kTIMConv_Group`message_elem_array = new List<Elem>{new Elem{elem_type = TIMElemType.kTIMElem_Custom,custom_elem_data = "",custom_elem_desc = "",custom_elem_ext = ""}}};StringBuilder messageId = new StringBuilder(128);TIMResult res = TencentIMSDK.MsgSendMessage(conv_id, TIMConvType.kTIMConv_C2C, message, messageId, (int code, string desc, string json_param, string user_data)=>{// Async message sending result});// The message ID messageId returned when the message is sent}
Was this page helpful?