VBS file to open new IM to multiple contacts (Windows Mess..

Andrew

Distinguished
Mar 31, 2004
2,439
0
19,780
Archived from groups: microsoft.public.windowsxp.messenger (More info?)

I currently have some code that opens a new message to a
contact. I am trying to have it add multiple contacts,
but the AddContact method, is just bringing up the dialog
to select a contact with that particular contact
selected. I tried playing with the SendKeys to send the
Enter key and include that person. Besides my not liking
hacks like SendKeys it doesn't seem to always work and
haven't got it to work for a 3rd person. Any thoughts
would much be appreciated. Here is my code.

'Code Starts Here*******************************
On error resume next
Dim MsgrUIA
Dim msgContact
Dim msgContact2
Dim msgContact3
Dim msgContact4

Const sEmail = "Email1@SomeAddress.com"
Const sEmail2 = "Email2@SomeAddress.com"
Const sEmail3 = "Email3@SomeAddress.com"
Const sEmail4 = "Email4@SomeAddress.com"

Set MsgrUIA = CreateObject("Messenger.UIAutomation.1")
Set msgContact = MsgrUIA.GetContact(sEmail,"")
Set msgContact2 = MsgrUIA.GetContact(sEmail2,"")
Set msgContact3 = MsgrUIA.GetContact(sEmail3,"")
Set msgContact4 = MsgrUIA.GetContact(sEmail4,"")


Set myMessage = MsgrUIA.InstantMessage(msgContact)

If Not IsObject(myMessage) Then
MsgBox("You are not signed in.")
Else
'Add other contacts to this conversation
myMessage.AddContact(msgContact2)
set oShell = CreateObject("WScript.Shell")
oShell.SendKeys"{ENTER}"
oShell.SendKeys"{ENTER}"
MyMessage.AddContact(msgContact3)
oShell.SendKeys"{ENTER}"
oShell.SendKeys"{ENTER}"
MyMessage.AddContact(msgContact4)
oShell.SendKeys"{ENTER}"
End If

On Error GoTo 0
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.messenger (More info?)

I am not satisified, but I got the SendKeys way of doing
it to work. It appears that you need to put a Sleep in
there. Here is the version I have that works. Hoping to
find a way besides SendKeys, but this works for now.


'Code Starts Here
'Adds in First Contact
If msgContact.Status = 1 Then
MsgBox(sEmail & " is currently Offline.")
Else
Set myMessage = MsgrUIA.InstantMessage(msgContact)
i = i + 1
End If

'Adds in Second Contact
If msgContact2.Status = 1 Then
MsgBox(sEmail2 & " is currently Offline.")
ElseIf i = 0 Then
Set myMessage = MsgrUIA.InstantMessage(msgContact2)
i = i + 1
Else
myMessage.AddContact(msgContact2)
oShell.SendKeys"{ENTER}"
WScript.Sleep 100
End If

'Adds in Third Contact
If msgContact3.Status = 1 Then
MsgBox(sEmail3 & " is currently Offline.")
ElseIf i = 0 Then
Set myMessage = MsgrUIA.InstantMessage(msgContact3)
i = i + 1
Else
myMessage.AddContact(msgContact3)
oShell.SendKeys"{ENTER}"
WScript.Sleep 100
End If
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.messenger (More info?)

<anonymous@discussions.microsoft.com> wrote in message
> I am not satisified, but I got the SendKeys way of doing
> it to work.
SendKeys has saved me a lot over the years; it may be dirty but it saves time and gets the
job done :)
____________________________________________
Jonathan Kay
Microsoft MVP - Windows Messenger/MSN Messenger
Associate Expert
http://www.microsoft.com/windowsxp/expertzone/
Messenger Resources - http://messenger.jonathankay.com
All posts unless otherwise specified are (c) 2005 Jonathan Kay.
You *must* contact me for redistribution rights.