View Single Post
  #1  
Old May 24th 06, 06:40 PM posted to microsoft.public.outlook.program_forms
GregCost
external usenet poster
 
Posts: 3
Default Automating Outlook .msg form works but email not sent immediately

The automation code only loads and makes visible an untitled.msg form
(separate from my project), the main form of Outlook is not loaded. In the
..msg form I can load the contents of the Clipboard, change it, add text, etc.
Clicking the Send Key from the Outlook .msg toolbar works except the message
queues until the next time I’m in Outlook’s main form and I hit the
“SEND/RECEIVE” key. Is there an option in Outlook that sends a .msg when
the send key is clicked from the .msg form?

Why do it this way? … you might ask. For a couple of reasons:

1.I do not have to re-invent the wheel “so to speak” make available all of
the necessary fields, options, addressee and address lists etc. inside my
project.

2.I do not have to worry about cleanup. The native send closes the outlook
..msg object

3.Everything the user needs is there in a format that they are familiar and
comfortable using.

4. I use vs2003 and I had many problems pasting the contents of the
clipboard when it was mixed between Text, Graphics and HTML, etc. I
understand this process has been simplified in VS2005 which I am not ready to
purchase

Any help GREATLY appreciated!

Dim olApp As Outlook.Application
Dim olmailitem As Object Dim olNs As Outlook.NameSpace
Dim olMail As Outlook.MailItem

Try
olApp = CreateObject("Outlook.Application")
olNs = olApp.GetNamespace("MAPI")
olNs.Logon()
olMail = olApp.CreateItem(olmailitem)
olMail.Display()
SendKeys.SendWait("{TAB}")
System.Threading.Thread.Sleep(50)
SendKeys.SendWait("{TAB}")
System.Threading.Thread.Sleep(50)
SendKeys.SendWait("{TAB}")
System.Threading.Thread.Sleep(50)
SendKeys.SendWait("{TAB}")
System.Threading.Thread.Sleep(50)
SendKeys.SendWait("^v")
System.Threading.Thread.Sleep(50)

Catch ex As COMException
MessageBox.Show("Error accessing Word document.")
End Try

Ads