I.. NetAddAPIReferences
1,In Solution Explorer. Right-click Properties and select "add reference"
2,Select"Com"Tab, select"Messenger API Type Library"
3,"Messgerapi"Component
2. Add a user list (two methods are available)
1,Use "file"->"Import contacts from saved files" in the format*. CTTThe format is as follows:
<? XML version = "1.0"?>
<Messenger>
<Service name = "Microsoft RTC instant messaging">
<Contactlist>
<Contact> hxuedong@nmdsy.com </contact>
<Contact> cyaodong@nmdsy.com </contact>
<Contact> sjianli@nmdsy.com </contact>
<Contact> fdg@nmdsy.com </contact>
</Contactlist>
</Service>
</Messenger>
Unfortunately, groups cannot be created here. This is also the recommended method.
2,PassAPIAdd functions, supplemented by keyboard Functions
(1) To createTxtFile, each row is a mailbox name
Hxuedong@nmdsy.com
Cyaodong@nmdsy.com
(2) Read cyclicallyTxtFile, and call the following functions
Messengerapi. messengerclass G1 =NewMessengerapi. messengerclass ();//. Messengernativeclass ();
G1.addcontact (0,Mailbox name);
System. Windows. Forms. sendkeys. Send ('\ R'. tostring ());//Call the keyboardAPIFunction (equivalent to clicking enter)
System. Windows. Forms. sendkeys. Send ('\ R'. tostring ());//Call the keyboardAPIFunction (equivalent to clicking enter)
This method is not recommended
2. PassAPIFunction sending information
Messengerapi. Messenger M1 =NewMessengerapi. messengerclass ();//InstantiationAPIClass
Messengerapi. imessgerwindow m_window;
ObjectContact = m1.getcontact (Destination mailbox name,"");//Obtain the target user'sContact
M_window = (messengerapi. imessential gerwindow) m1.instantmessage (contact );//Open the dialog box
If(M_window.isclosed)
{
M_window.show ();
}
System. Windows. Forms. sendkeys. Send ("UseProgramSent information");//Send message
System. Windows. Forms. sendkeys. Send ('\ R'. tostring ());//Simulate carriage return
System. Windows. Forms. sendkeys. Send ('\ R'. tostring ());//Simulate carriage return
3. Application scenarios
Combined with application systems,ServerTerminal passMessengerSend a message to the client. The disadvantage is thatServerTerminal installationWindows MessengerAnd cannot lock the keyboard (because the keyboard must be simulated ). BecauseMessgerThe backend library of is not public, so this is the only option.