# IMeetingChatController::SendChatMsgTo fails

**URL:** <https://devforum.zoom.us/t/imeetingchatcontroller-sendchatmsgto-fails/113099>\
**Category:** Meeting SDK\
**Created:** [July 4, 2024, 10:37pm UTC](https://devforum.zoom.us/t/imeetingchatcontroller-sendchatmsgto-fails/113099 "2024-07-04T22:37:09Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [July 8, 2024, 6:08am UTC](https://devforum.zoom.us/t/imeetingchatcontroller-sendchatmsgto-fails/113099/2 "2024-07-08T06:08:24Z")

</div>

@seungkoo I’ve just tried sending a chat message from the main thread and it works.

Are you trying to send a chat message from the onChatMsgNotification method itself?

```auto
	if (chatDemo) {
		IMeetingChatController* meetingchatcontroller= m_pMeetingService->GetMeetingChatController();
		meetingchatcontroller->SetEvent(new MeetingChatEventListener(&turnOnSendVideoAndAudio, &turnOffSendVideoandAudio));

		// Convert std::wstring to std::string (UTF-8)
		std::wstring wstr = L"Hello world!";
		std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
		std::string str = converter.to_bytes(wstr);

		// Ensure zchar_t is defined as char if not already defined
		typedef char zchar_t;

		char charArray[1024]; // Choose an appropriate size
		std::strncpy(charArray, str.c_str(), sizeof(charArray));

		// Ensure null-termination
		charArray[sizeof(charArray) / sizeof(charArray[0]) - 1] = '\0';

		const zchar_t* constCharArray = charArray;

		IChatMsgInfoBuilder* chatbuilder = meetingchatcontroller->GetChatMessageBuilder();
		chatbuilder->SetReceiver(0);
		chatbuilder->SetMessageType(SDKChatMessageType_To_All);
		chatbuilder->SetContent(constCharArray);
		chatbuilder->Build();
	
		meetingchatcontroller->SendChatMsgTo(chatbuilder->Build());

	}

```

---

_[View the full topic](https://devforum.zoom.us/t/imeetingchatcontroller-sendchatmsgto-fails/113099)._
