Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Interop / September 2007

Tip: Looking for answers? Try searching our database.

Capture Message Body with the ItemSend Event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
allan.awcs@gmail.com - 07 Sep 2007 11:03 GMT
I am using VS2005 and wish to record details of an e-mail send from my
app but I can't seem to update my form when the message is sent. I
have a simple form with one text box (txtMessage) and a button
(btnMail). Clicking btnMail fires up Outlook and when the message is
sent the ItemSend and Send events do fire but the do not allow me to
update my text box. The MsgBox do not display either but the do when i
comment out the txtMessage lines. What am I doing wrong??? It is as if
my form is not accessible programatically in the outlook event code. I
am using the following code:

Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports System.Data
Imports System.Data.Common
Imports Microsoft.Office.Interop.Outlook
Imports Microsoft.Office.Interop
Public Class frmMailTest
   Dim WithEvents oApp As New Outlook.Application
   Dim WithEvents oMsg As Outlook.MailItem
   Private Sub btnMail_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnMail.Click
       oMsg = oApp.CreateItem(OlItemType.olMailItem)
       With oMsg
           .To = "test@test.com"
           .Subject = "Subject"
           .BodyFormat = OlBodyFormat.olFormatPlain
           .Body = "Type your message here"
           .Display()
       End With
   End Sub
   Private Sub oApp_ItemSend(ByVal Item As Object, ByRef Cancel As
Boolean) Handles oApp.ItemSend
       txtMessage.Text = Item.body.ToString
       MsgBox("Mail Sent")
   End Sub
   Private Sub oMsg_Send(ByRef Cancel As Boolean) Handles oMsg.Send
       txtMessage.Text = oMsg.Body.ToString
       MsgBox("Mail Sent")
   End Sub
End Class
Brian Tillman - 10 Sep 2007 16:08 GMT
> I am using VS2005 and wish to record details of an e-mail send from my
> app but I can't seem to update my form when the message is sent. I
[quoted text clipped - 5 lines]
> my form is not accessible programatically in the outlook event code. I
> am using the following code:

Code questions are best discussed in microsoft.public.outlook.program_vba or
microsoft.public.outlook.program_addins
Signature

Brian Tillman [MVP-Outlook]

aj - 10 Sep 2007 18:41 GMT
> allan.a...@gmail.com <allan.a...@gmail.com> wrote:
> > I am using VS2005 and wish to record details of an e-mail send from my
[quoted text clipped - 11 lines]
> --
> Brian Tillman [MVP-Outlook]

Thanks - I will post there
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.