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

SenderName Value



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 19th 07, 01:45 AM posted to microsoft.public.outlook.program_vba
Mark Ivey
external usenet poster
 
Posts: 15
Default SenderName Value

Thanks Sue...


"Sue Mosher [MVP-Outlook]" wrote in message
...
You mean this statement? (Please, please tell us which statement is causing
problems rather than giving a line number.)

Set objFolder =
Outlook.Session.Folders("2007").Folders(objItem.Se nderName)

First, there's no object named Outlook in your code.

Second, you already have a Namespace object through which you can access the
Folders collection. You instantiated it with this statement:

Set objNS = Application.GetNamespace("MAPI")

Therefore, the correct statement, assuming you have a .pst file with the
display name 2007, would be:

Set objFolder = objNS.Folders("2007").Folders(objItem.SenderName)
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Mark Ivey" wrote in message
...
Sue,

Can you tell me what is wrong with my code below? I cannot seem to figure
out the right way to reference the SenderName value. It keeps throwing the
following error for line 9.

Run-time error '91':

Object variable or With block variable not set

'_________________________________________________ _________________________________
Sub MoveSelectedMessagesToFolder()
On Error Resume Next

Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder =
Outlook.Session.Folders("2007").Folders(objItem.Se nderName)

If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If

If Application.ActiveExplorer.Selection.Count = 0 Then
'Require that this procedure be called only when a message is
selected
Exit Sub
End If

For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move objFolder
End If
End If
Next

Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub
'_________________________________________________ _________________________________



"Sue Mosher [MVP-Outlook]" wrote in message
...
Session.Folders returns the collection of top-level folders, i.e. all the
individual .pst files or mailboxes. To get a non-default folder, you need
to
walk the folder hierarchy starting with that collections or use a function
that does that for you. See
http://www.outlookcode.com/d/code/getfolder.htm

"Mark Ivey" wrote in message
...
Thanks for the info Sue...

Here is some code I found and altered a bit on the web from Eric
Legault -
B.A, MCP, MCSD, Outlook MVP. My problem is not knowing how to reference
the
subfolder I need due to these security items I have mentioned. Do you
think
the code below should work for Outlook 2003? If not, could you make a
suggestion.

My biggest concern is this line: "Set objFolder =
Outlook.Session.Folders("2007" & objItem.SenderName)"
How do I reference a subfolder in my personal folders list with the
variable
"SenderName"?

'_________________________________________________ _________________________________
Sub MoveSelectedMessagesToFolder()
On Error Resume Next

Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = Outlook.Session.Folders("2007" & objItem.SenderName)

If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If

If Application.ActiveExplorer.Selection.Count = 0 Then
'Require that this procedure be called only when a message is
selected
Exit Sub
End If

For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move objFolder
End If
End If
Next

Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub
'_________________________________________________ _________________________________

"Sue Mosher [MVP-Outlook]" wrote in message
...
Outlook 2002 VBA will give you security prompts, but Outlook 2003 won't,
as
long as you derive all objects from the intrinsic Application object.

Greg's suggestion doesn't help, BTW, because the SaveAs method triggers a
security prompt.


"Mark Ivey" wrote in message
...

I am designing it at home in Outlook 2002, but plan on using it at work
for
Outlook 2003.

VBA (and VBS if needed).

Is there a way to get the SenderName Value via code?

From what I can tell, this is trapped behind some of the security
features
in Outlook.

I am wanting to reference this value so I can utilize it in an effort
to
make an archiving macro.







 




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
Change SenderName Property Jan-Henrik Horstmann Outlook and VBA 1 March 9th 07 07:37 AM
Redemption to return the DisplayName or SenderName bobdydd Outlook and VBA 2 May 30th 06 08:33 PM
How to change read only SenderName and SenderEmailAddress [email protected] Outlook - General Queries 3 April 19th 06 08:22 PM


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