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

Change subject in all emails



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 25th 06, 05:03 PM posted to microsoft.public.outlook.program_vba
DB01
external usenet poster
 
Posts: 1
Default Change subject in all emails

....hope this is not a double post....

I'm stumped. I use Google desktop search and most of you know that it
does not search outlook categories. So I had an idea, check all mail
in all folders (including personal folders) and modify the subject by
adding to it the list of categories. So, for example, if the subject
were "planning meeting notes" and the categories were "planning",
"notes", "projectx", "customerz", I'd like the new subject line to read
"planning meeting notes [lplanning lnotes lprojectx lcustomerz]" I
started writing the code, but quickly became overwhelmed. Is there
someone on the list who has done something like this before (or
something close) so that I may borrow your code? Much appreciated!

DB01

Ads
  #2  
Old May 25th 06, 09:44 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Change subject in all emails

Try running this macro on the current folder:

Sub AppendCategoriesToSubjectLine()
Dim objItems As Outlook.Items
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem, objItem As Object

Set objFolder = ActiveExplorer.CurrentFolder
Set objItems = objFolder.Items

For Each objItem In objItems
If objItem.Class = olMail Then
Set objMail = objItem
If objMail.Categories "" Then
objMail.Subject = objMail.Subject & " [" &
objMail.Categories & "]"
objMail.Save
End If
End If
Set objMail = Nothing
Next

Set objItem = Nothing
Set objItems = Nothing
Set objMail = Nothing
Set objFolder = Nothing
End Sub

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"DB01" wrote:

....hope this is not a double post....

I'm stumped. I use Google desktop search and most of you know that it
does not search outlook categories. So I had an idea, check all mail
in all folders (including personal folders) and modify the subject by
adding to it the list of categories. So, for example, if the subject
were "planning meeting notes" and the categories were "planning",
"notes", "projectx", "customerz", I'd like the new subject line to read
"planning meeting notes [lplanning lnotes lprojectx lcustomerz]" I
started writing the code, but quickly became overwhelmed. Is there
someone on the list who has done something like this before (or
something close) so that I may borrow your code? Much appreciated!

DB01


  #3  
Old May 28th 06, 09:24 AM posted to microsoft.public.outlook.program_vba
Zoom
external usenet poster
 
Posts: 4
Default Change subject in all emails

I have a problem in adding value to a custom field created in outlook2003. I
can able to create a custom field in outlook inbox, but i'm not able to add
value to it. To my knowledge the code seems to be fine and the value is
assigned to the custom field but something is blocking to display it.
Herewith i've pasted my code for your reference.

Dim olNamespace As Outlook.NameSpace
Dim cf As Outlook.MAPIFolder
Set olNamespace = Outlook.Application.GetNamespace("MAPI")
Set cf = olNamespace.GetDefaultFolder(olFolderInbox)
Dim emailitem As Outlook.MailItem

For Each emailitem In cf.Items
Dim prop As Outlook.UserProperty
Set prop = emailitem.UserProperties.Add("HowOld", olText, False, Nothing)
prop.Value = DateDiff("d", emailitem.ReceivedTime, Now) & " days."
emailitem.Save
set prop = nothing
Next


Note: I'm using vb 6.0
Value is not getting displayed. Whereas i tried to display the column value
using "MsgBox emailitem.ItemProperties("HowOld")". i'm getting the message
box with value


I created a custom view using the below code

==========================================
Sub AddColumnToView(ByVal strName As String, ByVal strHead As String, _
ByVal strProp As String)
'Creates a new Table view and adds a column.

Dim objView As View
Dim objViews As Views
'Set a reference to the MSXML parser.
Dim objXMLDoc As New MSXML2.DOMDocument
'Dim objNode As MSXML2.IXMLDOMNode
Dim objRoot As MSXML2.IXMLDOMNode

On Error GoTo AddColumnToView_Err
Set objViews = _

Application.GetNamespace(Type:="MAPI").GetDefaultF older(FolderType:=olFolderInbox).Views
'Set objView = objViews.Add(Name:=strName, ViewType:=olTableView, _
' SaveOption:=olViewSaveOptionAllFoldersOfType)

Set objView = objViews.Add(Name:=strName, ViewType:=olTableView, _
SaveOption:=olViewSaveOptionThisFolderEveryone)


'Load the XML schema into the parser.
objXMLDoc.loadXML bstrXML:=objView.XML
'Create a reference to the root element.
Set objRoot = objXMLDoc.documentElement
'Walk the tree to obtain a column node.
With objRoot.insertBefore(newChild:=objXMLDoc.createEle ment("column"), _
refChild:=objRoot.selectNodes(querystring:=("colum n")).Item(Index:=5))
'Add properties to the new column.

..appendChild(newChild:=objXMLDoc.createElement(ta gName:="Heading")).Text =
strHead

..appendChild(newChild:=objXMLDoc.createElement(ta gName:="prop")).Text =
strProp

'.appendChild(newChild:=objXMLDoc.createElement(ta gName:="sort")).Text =
"desc"

..appendChild(newChild:=objXMLDoc.createElement(ta gName:="width")).Text = 50

..appendChild(newChild:=objXMLDoc.createElement(ta gName:="type")).Text =
"string"

'.appendChild(newChild:=objXMLDoc.createElement(ta gName:="type")).Text = "i4"
End With
'Copy the schema from the parser to the View object.
objView.XML = objXMLDoc.XML
'Save the schema.
objView.Save
'Apply the changes to the view.
objView.Apply


AddColumnToView_End:
Set objXMLDoc = Nothing
Exit Sub
AddColumnToView_Err:
MsgBox "Error Source: " & Err.Source & " ::Error Number: " &
Str$(Err.Number) & " ::Error Desc: " & Err.Description & " " & strProp
Resume AddColumnToView_End
End Sub
==========================================


I called the above method using

Call AddColumnToView(strName:="New Table View2", strHead:="HowOld", _
strProp:="urn: schemas: mailheader: original
-Recipient")





"Eric Legault [MVP - Outlook]" wrote:

Try running this macro on the current folder:

Sub AppendCategoriesToSubjectLine()
Dim objItems As Outlook.Items
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem, objItem As Object

Set objFolder = ActiveExplorer.CurrentFolder
Set objItems = objFolder.Items

For Each objItem In objItems
If objItem.Class = olMail Then
Set objMail = objItem
If objMail.Categories "" Then
objMail.Subject = objMail.Subject & " [" &
objMail.Categories & "]"
objMail.Save
End If
End If
Set objMail = Nothing
Next

Set objItem = Nothing
Set objItems = Nothing
Set objMail = Nothing
Set objFolder = Nothing
End Sub

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"DB01" wrote:

....hope this is not a double post....

I'm stumped. I use Google desktop search and most of you know that it
does not search outlook categories. So I had an idea, check all mail
in all folders (including personal folders) and modify the subject by
adding to it the list of categories. So, for example, if the subject
were "planning meeting notes" and the categories were "planning",
"notes", "projectx", "customerz", I'd like the new subject line to read
"planning meeting notes [lplanning lnotes lprojectx lcustomerz]" I
started writing the code, but quickly became overwhelmed. Is there
someone on the list who has done something like this before (or
something close) so that I may borrow your code? Much appreciated!

DB01


 




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
How do I change the font in the subject line of an appointment kristilynn777 Outlook - Calandaring 1 May 24th 06 05:28 AM
User cannot change Meeting Subject for local calendar Eric McCombs Outlook - Calandaring 0 April 5th 06 03:58 PM
Change email subject line... silas Outlook Express 1 February 27th 06 11:59 PM
Change advanced find to 'subject field and message body' ©® Outlook - General Queries 0 February 23rd 06 02:57 PM
some emails not opening, subject line only, not message Bill Outlook - General Queries 4 January 26th 06 01:31 PM


All times are GMT +1. The time now is 04:01 PM.


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.