View Single Post
  #10  
Old May 5th 06, 07:49 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Help with prompting for a subject

Am 3 May 2006 23:24:20 -0700 schrieb kaiser:

Ok. All you need is this:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)
If Trim(Item.Subject) = vbNullString Then
MsgBox ("There is no subject - enter a subject and try again")
'somehow stop the email from going but dont close the email
Cancel=True
End If
End Sub

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Okay - thanks

I have this in the modules section

Private Sub Application_Startup()
Set m_colInspectors = Application.Inspectors
End Sub



and this in the ThisOUtlookSession


Option Explicit
Private WithEvents m_colInspectors As Outlook.Inspectors
Private WithEvents CurrentInspector As Outlook.Inspector





Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)
If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
If Item.Now = vbNullString Then
MsgBox ("There is no subject - enter a subject and try again")
'somehow stop the email from going but dont close the email
End If
Set CurrentInspector = Inspector
End If
End If

End Sub

Private Sub Application_Startup()
Set m_colInspectors = Application.Inspectors
End Sub


Private Sub CurrentInspector_Activate()
Dim oMail As Outlook.MailItem
If Len(UserForm1.SelectedSubject) Then
Set oMail = CurrentInspector.CurrentItem
oMail.Subject = UserForm1.SelectedSubject
End If
Set CurrentInspector = Nothing
End Sub


Private Sub m_colInspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
If Inspector.CurrentItem.EntryID = vbNullString Then
UserForm1.SelectedSubject = vbNullString
UserForm1.Show
Set CurrentInspector = Inspector
End If
End If
End Sub




Thanks

Ads