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

A code that adds category to an outgoing mail message in outlook



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 1st 09, 05:16 PM posted to microsoft.public.outlook.program_vba
newED
external usenet poster
 
Posts: 1
Default A code that adds category to an outgoing mail message in outlook


This code adds a category name to an outgoing mail message in outlook.
However when using it - the subject disappears. Do you happen to know
why and how to fix it ?

Public Sub TagMessage()
Set objOL = CreateObject("Outlook.Application")
If Not objOL.ActiveInspector Is Nothing Then
Set objItem = objOL.ActiveInspector.CurrentItem
objItem.Categories = "my category"
End If
End Sub

Thanks for your help


--
newED
------------------------------------------------------------------------
newED's Profile: http://www.thecodecage.com/forumz/member.php?userid=603
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=121671

Ads
  #2  
Old August 1st 09, 06:20 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default A code that adds category to an outgoing mail message in outlook

There's no reason I can see for subject to become blank.

If this is running in the Outlook VBA project use Application and don't ever
use CreateObject or New:

If Not Application.ActiveInspector Is Nothing Then

etc.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"newED" wrote in message
...

This code adds a category name to an outgoing mail message in outlook.
However when using it - the subject disappears. Do you happen to know
why and how to fix it ?

Public Sub TagMessage()
Set objOL = CreateObject("Outlook.Application")
If Not objOL.ActiveInspector Is Nothing Then
Set objItem = objOL.ActiveInspector.CurrentItem
objItem.Categories = "my category"
End If
End Sub

Thanks for your help


--
newED
------------------------------------------------------------------------
newED's Profile: http://www.thecodecage.com/forumz/member.php?userid=603
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=121671


  #3  
Old August 1st 09, 09:39 PM posted to microsoft.public.outlook.program_vba
Simon Lloyd
external usenet poster
 
Posts: 1
Default A code that adds category to an outgoing mail message in outlook


For everything you need to know on sending mail take a look here
'Example Code for sending mail from Excel'
(http://www.rondebruin.nl/sendmail.htm)

newED;438449 Wrote:
This code adds a category name to an outgoing mail message in outlook.
However when using it - the subject disappears. Do you happen to know
why and how to fix it ?

Public Sub TagMessage()
Set objOL = CreateObject("Outlook.Application")
If Not objOL.ActiveInspector Is Nothing Then
Set objItem = objOL.ActiveInspector.CurrentItem
objItem.Categories = "my category"
End If
End Sub

Thanks for your help



--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=121671

  #4  
Old August 2nd 09, 04:11 AM posted to microsoft.public.outlook.program_vba
newED[_2_]
external usenet poster
 
Posts: 1
Default A code that adds category to an outgoing mail message in outlook


thank Ken,

unfortunately, it does get blank everytime I use this code.

Btw, I tried your offered suggestion. However I'm not quite sure I
understood it, because now I get a compile error:
" Method or data not found" - with the new code line highlighted

should I make anymore changes in the code so that your offered change
would work?

Thanks

'Ken Slovak - [MVP - Outlook Wrote:
;438482']There's no reason I can see for subject to become blank.

If this is running in the Outlook VBA project use Application and don't
ever
use CreateObject or New:

If Not Application.ActiveInspector Is Nothing Then

etc.

--
Ken Slovak
[MVP - Outlook]
'Slovak Technical Services Home' (http://www.slovaktech.com)
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
'Slovak Technical Services Products'
(http://www.slovaktech.com/products.htm)


"newED" wrote in message
...

This code adds a category name to an outgoing mail message in

outlook.
However when using it - the subject disappears. Do you happen to

know
why and how to fix it ?

Public Sub TagMessage()
Set objOL = CreateObject("Outlook.Application")
If Not objOL.ActiveInspector Is Nothing Then
Set objItem = objOL.ActiveInspector.CurrentItem
objItem.Categories = "my category"
End If
End Sub

Thanks for your help


--
newED

------------------------------------------------------------------------
newED's Profile: 'The Code Cage Forums - View Profile: newED'

(http://www.thecodecage.com/forumz/member.php?userid=603)
View this thread:
'A code that adds category to an outgoing mail message in outlook -

The Code Cage Forums'
(http://www.thecodecage.com/forumz/sh...d.php?t=121671)



--
newED
------------------------------------------------------------------------
newED's Profile: http://www.thecodecage.com/forumz/member.php?userid=603
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=121671

  #5  
Old August 3rd 09, 02:29 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default A code that adds category to an outgoing mail message in outlook

The suggestion I made was only if the code is running in the Outlook VBA
project, not in Excel or some other application. Is the code running in
Outlook? If not then go back to using CreateObject().

Unless there's additional code you haven't shown, the code you did show does
nothing to touch Subject so I can't see how the subject would be blanked.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"newED" wrote in message
...

thank Ken,

unfortunately, it does get blank everytime I use this code.

Btw, I tried your offered suggestion. However I'm not quite sure I
understood it, because now I get a compile error:
" Method or data not found" - with the new code line highlighted

should I make anymore changes in the code so that your offered change
would work?

Thanks


  #6  
Old August 3rd 09, 03:21 PM posted to microsoft.public.outlook.program_vba
newED[_3_]
external usenet poster
 
Posts: 1
Default A code that adds category to an outgoing mail message in outlook


'Ken Slovak - [MVP - Outlook Wrote:
;439563']The suggestion I made was only if the code is running in the
Outlook VBA
project, not in Excel or some other application. Is the code running
in
Outlook? If not then go back to using CreateObject().

Unless there's additional code you haven't shown, the code you did show
does
nothing to touch Subject so I can't see how the subject would be
blanked.

--
Ken Slovak
[MVP - Outlook]
'Slovak Technical Services Home' (http://www.slovaktech.com)
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
'Slovak Technical Services Products'
(http://www.slovaktech.com/products.htm)


"newED" wrote in message
...

thank Ken,

unfortunately, it does get blank everytime I use this code.

Btw, I tried your offered suggestion. However I'm not quite sure I
understood it, because now I get a compile error:
" Method or data not found" - with the new code line highlighted

should I make anymore changes in the code so that your offered

change
would work?

Thanks




I found a different way to overcome this problem, withoutthe creating a
new object.
Anyway, it sloved my problem.
Thanks


--
newED
------------------------------------------------------------------------
newED's Profile: http://www.thecodecage.com/forumz/member.php?userid=603
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=121671

  #7  
Old August 3rd 09, 04:37 PM posted to microsoft.public.outlook.program_vba
Simon Lloyd[_2_]
external usenet poster
 
Posts: 1
Default A code that adds category to an outgoing mail message in outlook


Glad you're sorted, if possible post your solution here to aid others,
in any case:


--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=121671

  #8  
Old August 3rd 09, 06:50 PM posted to microsoft.public.outlook.program_vba
newED[_4_]
external usenet poster
 
Posts: 1
Default [SOLVED]: A code that adds category to an outgoing mail message in outlook


Simon Lloyd;439752 Wrote:
Glad you're sorted, if possible post your solution here to aid others,
in any case:


off-course.

I used this simple code insteadץ
Apparently, it does the same thing in a much simpler way

Public Sub TagMessage()
ActiveInspector.CurrentItem.Categories = "ZZZ"
End Sub


--
newED
------------------------------------------------------------------------
newED's Profile: http://www.thecodecage.com/forumz/member.php?userid=603
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=121671

 




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
Why outlook adds =SMTP: to eply mail Berk337 Outlook - Installation 0 May 26th 08 03:20 AM
how do I code message send options for voting priority category? JC Outlook and VBA 1 January 3rd 08 05:31 PM
Adding line to outgoing message based on category? Rob F Outlook and VBA 1 August 23rd 07 03:08 PM
can I color code tasks with a category or otherwise make subcatego Arthur Outlook - Using Contacts 1 April 24th 06 12:37 AM
Run VBA Code from 'new mail message' on standard toolbar Carmi Outlook and VBA 8 March 31st 06 05:53 PM


All times are GMT +1. The time now is 11:38 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.