A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Help with prompting for a subject



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 26th 06, 04:09 PM posted to microsoft.public.outlook.program_vba
kaiser
external usenet poster
 
Posts: 8
Default Help with prompting for a subject

Hi

Can anyone please help me. I am trying to write a macro that does the
following.


When an email is opened (either a new email or a reply / forward) the
macro must check if there is content inthe subject line. If there is,
then it must do nothing but open the email ready for forward or reply,
however, if there is NO subject it must bring up a msgbox saying "No
Subject"


Can anyone help me with this? SOmeone the forum previously helped me
with the following code (which when opening an email, prompted you to
chose from one of five choices from a userform and would enter a
preassigned string inot the subject). Perhaps this code will help


Thnks!


under modules:


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


under ThisOutlookSession:
Option Explicit
Private WithEvents m_colInspectors As Outlook.Inspectors
Private WithEvents CurrentInspector As Outlook.Inspector


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


and obbiously had the userform

Ads
  #2  
Old April 26th 06, 06:00 PM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Help with prompting for a subject

Am 26 Apr 2006 07:09:49 -0700 schrieb kaiser:

You can add the code into the NewInspector procedure. Check
CurrentItem.Subject, if it´s blank then call MsgBox.

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


Hi

Can anyone please help me. I am trying to write a macro that does the
following.


When an email is opened (either a new email or a reply / forward) the
macro must check if there is content inthe subject line. If there is,
then it must do nothing but open the email ready for forward or reply,
however, if there is NO subject it must bring up a msgbox saying "No
Subject"


Can anyone help me with this? SOmeone the forum previously helped me
with the following code (which when opening an email, prompted you to
chose from one of five choices from a userform and would enter a
preassigned string inot the subject). Perhaps this code will help


Thnks!


under modules:


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


under ThisOutlookSession:
Option Explicit
Private WithEvents m_colInspectors As Outlook.Inspectors
Private WithEvents CurrentInspector As Outlook.Inspector


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


and obbiously had the userform

  #3  
Old April 27th 06, 12:42 PM posted to microsoft.public.outlook.program_vba
kaiser
external usenet poster
 
Posts: 8
Default Help with prompting for a subject

Thanks MIchael...but i cant get it to work? Can you assist? One thing
just struck me...obviously when i open an email the subject will be
blank as nothing is inputted yet...meant to say that when the "send"
button is clicked AND the subject line is blank it must bring up a
message box saying that the email subject line is blank...so no email
can go unless there is a subject line.
thanks

  #4  
Old April 28th 06, 07:05 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Help with prompting for a subject

Am 27 Apr 2006 03:42:06 -0700 schrieb kaiser:

Ok, in that case please use the ItemSend event instead of the NewInspector
event.

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


Thanks MIchael...but i cant get it to work? Can you assist? One thing
just struck me...obviously when i open an email the subject will be
blank as nothing is inputted yet...meant to say that when the "send"
button is clicked AND the subject line is blank it must bring up a
message box saying that the email subject line is blank...so no email
can go unless there is a subject line.
thanks

  #5  
Old April 28th 06, 09:15 AM posted to microsoft.public.outlook.program_vba
kaiser
external usenet poster
 
Posts: 8
Default Help with prompting for a subject

Hello MIchael

THanks - can you help me with the full text please? I am but a
beginner trying to fiddle my way thorugh

thanks!

  #6  
Old April 30th 06, 10:24 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Help with prompting for a subject

Am 28 Apr 2006 00:15:02 -0700 schrieb kaiser:

The IDE creates the event procedure automatically for you, simply click into
the Combobox above the code window on the left hand and select
"Application". Then click into the one on the right hand and select
"ItemSend".

Now move the code from the NewInspector event into the new one. Instead of
Inspector.CurrentItem you do have the ref onto the e-mail now directly via
the "Item" variable. So you need to replace NewInspector.CurrentItem by Item
now.

Call UserForm1.Show with a 1 as the argument. That means the Form will be
shown modal, i.e. the code execution stops until the form will be closed
(otherwise the e-mail would be sent out while your form is still shown).

Also copy the code from the Activate event into the ItemSend event after the
line: UserForm1.Show 1. That lines will be executed then after you have
closed the form.

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


Hello MIchael

THanks - can you help me with the full text please? I am but a
beginner trying to fiddle my way thorugh

thanks!

  #7  
Old May 2nd 06, 07:21 AM posted to microsoft.public.outlook.program_vba
kaiser
external usenet poster
 
Posts: 8
Default Help with prompting for a subject

I am sorry to be a pain michael, i cant get this to work. Can you
please drop the actual code onto this chat thread so that i can import
it then execute it line by line to see the effect?

  #8  
Old May 2nd 06, 07:46 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Help with prompting for a subject

Am 1 May 2006 22:21:53 -0700 schrieb kaiser:

Please show me what you´ve created so far. We can then see if there´s
something wrong.

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


I am sorry to be a pain michael, i cant get this to work. Can you
please drop the actual code onto this chat thread so that i can import
it then execute it line by line to see the effect?

  #9  
Old May 4th 06, 08:24 AM posted to microsoft.public.outlook.program_vba
kaiser
external usenet poster
 
Posts: 8
Default Help with prompting for a subject

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

  #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

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with prompting for a subject kaiser Outlook and VBA 0 April 26th 06 04:08 PM
Outlook prompting for Password Ismaelmvp3 Outlook - Using Forms 2 April 12th 06 04:11 PM
Setting Prompting for credentials in PRF Mike D. Outlook - General Queries 0 March 24th 06 10:39 PM
Hide Subject from others iblonger Outlook - Calandaring 4 February 25th 06 07:53 AM
Blank from and subject turboglide Outlook Express 2 January 14th 06 01:22 AM


All times are GMT +1. The time now is 07:51 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.