P
peter.sitskoorn
Hi,
I want to change to change the subject of a message in Outlook. For
that I have create some code to do so in .net. However, when I press
the button, nothing happens. I only get the bloody msgbox (it does
something, but not what I want...). Does anybody has any suggestions
how to get it working?
Here's the code:
Private Sub MyButton_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles MyButton.Click
Dim objOL As Outlook.Application
Dim objMsg As Object
Dim objAttachments As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim NewSubject As String
Dim olMail As Outlook.MailItem
On Error Resume Next
' Instantiate an Outlook Application object.
objOL = CreateObject("Outlook.Application")
' Get the collection of selected objects.
objSelection = objOL.ActiveExplorer.Selection
For Each objMsg In objSelection
'select the message and ask for a new subject, then save
If objMsg.Class Is olMail Then
NewSubject = InputBox("Geef het onderwerp van het
bericht", "Enter Subject", objMsg.Subject)
objMsg.Subject = NewSubject
objMsg.Save()
Else
End If
Next
'release objects
objMsg = Nothing
objSelection = Nothing
objOL = Nothing
MsgBox("Our CommandBar button was pressed, and the code has
ended!")
End Sub
Thanks
Peter
I want to change to change the subject of a message in Outlook. For
that I have create some code to do so in .net. However, when I press
the button, nothing happens. I only get the bloody msgbox (it does
something, but not what I want...). Does anybody has any suggestions
how to get it working?
Here's the code:
Private Sub MyButton_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles MyButton.Click
Dim objOL As Outlook.Application
Dim objMsg As Object
Dim objAttachments As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim NewSubject As String
Dim olMail As Outlook.MailItem
On Error Resume Next
' Instantiate an Outlook Application object.
objOL = CreateObject("Outlook.Application")
' Get the collection of selected objects.
objSelection = objOL.ActiveExplorer.Selection
For Each objMsg In objSelection
'select the message and ask for a new subject, then save
If objMsg.Class Is olMail Then
NewSubject = InputBox("Geef het onderwerp van het
bericht", "Enter Subject", objMsg.Subject)
objMsg.Subject = NewSubject
objMsg.Save()
Else
End If
Next
'release objects
objMsg = Nothing
objSelection = Nothing
objOL = Nothing
MsgBox("Our CommandBar button was pressed, and the code has
ended!")
End Sub
Thanks
Peter