W
WKK
Hi,
I am trying to write a VB.NET 2005 application, that should automate word
2003 for sending e-mails.
Right now my application is able to open a document template in Word 2003,
open the mail envelop, fill the mail envelop with data from the application.
The user may then click the send button and the e-mail is sent properly.
After that however my application freezes as well as my Outlook client. In
task manager I can see that Word.exe is still running. After killing
Word.exe my application and Outlook seem to work properly again.
Here is a sample Windows Application that demonstrates the problem:
Option Strict Off
Imports Word = Microsoft.Office.Interop.Word Imports Outlook =
Microsoft.Office.Interop.Outlook
Public Class Form3
Dim oApp As Word.Application
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim sPath As String = "C:\TEMP\"
oApp = New Word.Application
Dim oDoc As Word.Document = oApp.Documents.Open(sPath & "Test.doc")
oApp.Visible = True
oDoc.SaveAs(sPath & "Test1.doc")
oDoc.ActiveWindow.EnvelopeVisible = True
Dim oItem As Outlook.MailItem = CType(oDoc.MailEnvelope.Item,
Outlook.MailItem)
oItem.Subject = "Test"
oItem.To = TextBox1.Text
'oItem.Close(Outlook.OlInspectorClose.olSave)
'oDoc.Close()
End Sub
End Class
The problem is somehow linked to using the Outlook.MailItem property. If not
using the Outlook.MailItem property but filling the mail envelop fields
manually my application does not freeze after pressing the send button.
Am I making anything wrong? Any help would be appreciated.
Thanks,
Wulf
I am trying to write a VB.NET 2005 application, that should automate word
2003 for sending e-mails.
Right now my application is able to open a document template in Word 2003,
open the mail envelop, fill the mail envelop with data from the application.
The user may then click the send button and the e-mail is sent properly.
After that however my application freezes as well as my Outlook client. In
task manager I can see that Word.exe is still running. After killing
Word.exe my application and Outlook seem to work properly again.
Here is a sample Windows Application that demonstrates the problem:
Option Strict Off
Imports Word = Microsoft.Office.Interop.Word Imports Outlook =
Microsoft.Office.Interop.Outlook
Public Class Form3
Dim oApp As Word.Application
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim sPath As String = "C:\TEMP\"
oApp = New Word.Application
Dim oDoc As Word.Document = oApp.Documents.Open(sPath & "Test.doc")
oApp.Visible = True
oDoc.SaveAs(sPath & "Test1.doc")
oDoc.ActiveWindow.EnvelopeVisible = True
Dim oItem As Outlook.MailItem = CType(oDoc.MailEnvelope.Item,
Outlook.MailItem)
oItem.Subject = "Test"
oItem.To = TextBox1.Text
'oItem.Close(Outlook.OlInspectorClose.olSave)
'oDoc.Close()
End Sub
End Class
The problem is somehow linked to using the Outlook.MailItem property. If not
using the Outlook.MailItem property but filling the mail envelop fields
manually my application does not freeze after pressing the send button.
Am I making anything wrong? Any help would be appreciated.
Thanks,
Wulf