Sending keys from vb.2005 to Outlook



Please forgive me if this is the incorrect forum and direct me to the corret

1. I am developing in VS 2005 / VB. Target is a variety of generations of
Outlook. (I think the folk paying the bill are several major releases back.)
Hence, VSTO is out of the question. And the PIA's are too because the
customer sends the software around the world without charge.

2. The customer wants only one outlook window open on the desk top. He may
be anywhere in Outlook when I need to tell it what to do.

3. Here is the current code that half works - I get the Outlook window
activated but my sendkeys doesn't seem to do anything.
Suggestions please?

Private Sub go(ByVal shortname As String, Optional ByVal params As
String = "", Optional ByVal keys As String = "")
Dim procs() As Process = Process.GetProcessesByName(shortname)
If procs.Length > 1 Then
MsgBox(String.Format("You have more than one instance of {0}
running.", shortname))
Exit Sub
ElseIf procs.Length = 1 Then
' switch to that window
Me.TextBox1.Text &= "Activating " & shortname & keys & vbCrLf
If keys <> "" Then
End If
Me.TextBox1.Text &= "Starting" & shortname & " " & " " & params
& " " & keys & vbCrLf
Process.Start(shortname, params)
If keys <> "" Then System.Windows.Forms.SendKeys.Send(keys)
End If
End Sub
Private Sub bActivate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles bActivate.Click
Select Case ComboBox1.SelectedItem.ToString
Case "Windows Address Book" : go("wab")
Case "Outlook" : go("OUTLOOK", "/select outlook:contacts",
"%GC") ' Alt G +A should give me the contacts
End Select
End Sub

I'd be open to creating an outlook application internally and using that if
it did the job and did not require VSTO and anything besides Framework 2.0 on
the customer side.


Al Christoph
Senior Consultant and Owner
Three Bears Software, LLC
just right software @ just right prices @
A Microsoft Certified Partner (ISV)
Working on utilities for Windows Mail for Vista.

Al Christoph

This has been resolved. All that was needed was a slight delay before
sending the keys.

More to the point there were far better ways involving the careful use of
command line switches to accomplish my ends without doing a sendkeys.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question