Hi
I have written some VBA in Access 2003 to bring up an MSN instant message window and send a message to that contact. The only problem is, I seem to be able to do everything except actually send the message! I think this feature may have been removed from the API. Anyway, here's the code: -
Private Sub SendIM()
Dim header As String
Dim objmsgr As MessengerAPI.Messenger
Dim contact As MessengerAPI.IMessengerContact
Set objmsgr = New MessengerAPI.Messenger
Set contact = objmsgr.GetContact("anyone@hotmail.com", objmsgr.MyServiceId)
objmsgr.InstantMessage contact
[this is where I'm stuck]
End Sub
Apparently SendKeys has to be used because there is no code to actually put a message into the window and click send. Is there a better way of doing this
Many thanks in advance
Shelto

Using VBA to send an MSN instant message
SAlekseev
Our support engineer came up with the following code for you.
====================================< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Dim m_MSG As New MessengerAPI.Messenger
Dim m_Groups As MessengerAPI.IMessengerGroups 'MSN Groups
Dim m_Group As MessengerAPI.IMessengerGroup ' the contentin MSN group
Dim m_Contracts As MessengerAPI.IMessengerContacts 'all the contacts in MSN
Dim m_Contract As MessengerAPI.IMessengerContact 'each contact in MSN
Private Sub Command1_Click()
Dim i As Integer
'verify the message
If Trim(Text1.Text) = "" Then
MsgBox "the message is not null!", vbInformation, "Info"
Text1.SetFocus
Exit Sub
End If
'check the message is sent to all the contact or some one
If Combo1.ListIndex = 0 Then
Set m_Contracts = m_MSG.MyContacts
Else
Set m_Groups = m_MSG.MyGroups
Set m_Group = m_Groups.Item(Combo1.ListIndex - 1)
Set m_Contracts = m_Group.Contacts
End If
'send the message
For i = 0 To m_Contracts.Count - 1
Set m_Contract = m_Contracts.Item(i)
If Check1.Value = 1 Then
If m_Contract.Status = 2 Then
m_MSG.InstantMessage m_Contract 'open the message form
DoEvents
SendKeys Text1.Text 'write the message
DoEvents
SendKeys "{enter}" 'send the message
DoEvents
SendKeys "%{F4}" 'close the form
End If
Else
m_MSG.InstantMessage m_Contract
DoEvents
SendKeys Text1.Text
DoEvents
SendKeys "{enter}"
DoEvents
SendKeys "%{F4}"
End If
Next i
'send message successfully
If MsgBox("send successfully!clear the message or not ", vbInformation + vbYesNo, "info") = vbYes Then
Text1.Text = ""
Text1.SetFocus
Else
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
Unload Me
End
End Sub
Private Sub Form_Load()
Dim i As Integer
'Initialize the dropdownlist
Set m_Groups = m_MSG.MyGroups
With Combo1
.AddItem "all the groups"
For i = 0 To m_Groups.Count - 1
Set m_Group = m_Groups.Item(i)
.AddItem m_Group.Name
Next i
.ListIndex = 0
End With
End Sub
' Clean up any resources being used.
Private Sub Form_Unload(Cancel As Integer)
Set m_MSG = Nothing
Set m_Groups = Nothing
Set m_Group = Nothing
Set m_Contracts = Nothing
Set m_Contract = Nothing
======================================================
-brenda (ISV Buddy Team)
Kamii47
mafc