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

Sent Items



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 4th 09, 09:40 PM posted to microsoft.public.outlook.program_vba
JHP
external usenet poster
 
Posts: 8
Default Sent Items

I've written a Macro that moves sent email to the proper Mailbox without
hard-coding Mailbox name; working great with Exchange Accounts, but if this
same approch is used with PST Accounts...

I don't know how (where to begin) to match the Sent mail to the correct
folder, as the folder name can be renamed and may not match the
SentOnBehalfOfName?

Thank you for any assistance,


  #2  
Old May 5th 09, 09:52 PM posted to microsoft.public.outlook.program_vba
JHP
external usenet poster
 
Posts: 8
Default Sent Items

Maybe I need supply more information?

I am trying to determine if a sent email (from address) belongs to an
existing (visible) mailbox...

Lets say I have multiple accounts (PST files as I already have Exchange
folders working) setup - I want to be able to determine which account the
email was sent from.

I don't want to have to hard-code the folder name (Select Case to match
address to folder) as a (PST) mailbox can be renamed.

I thought of using StoreID but a sent email (Parent.StoreID) takes on the
Default account's ID.

Any help would be greatly appreciated,


"JHP" wrote in message
...
I've written a Macro that moves sent email to the proper Mailbox without
hard-coding Mailbox name; working great with Exchange Accounts, but if
this same approch is used with PST Accounts...

I don't know how (where to begin) to match the Sent mail to the correct
folder, as the folder name can be renamed and may not match the
SentOnBehalfOfName?

Thank you for any assistance,



  #3  
Old May 6th 09, 10:05 PM posted to microsoft.public.outlook.program_vba
Mark McGinty
external usenet poster
 
Posts: 25
Default Sent Items


"JHP" wrote in message
...
Maybe I need supply more information?

I am trying to determine if a sent email (from address) belongs to an
existing (visible) mailbox...

Lets say I have multiple accounts (PST files as I already have Exchange
folders working) setup - I want to be able to determine which account the
email was sent from.

I don't want to have to hard-code the folder name (Select Case to match
address to folder) as a (PST) mailbox can be renamed.

I thought of using StoreID but a sent email (Parent.StoreID) takes on the
Default account's ID.

Any help would be greatly appreciated,


I'm still a little unclear as to what you're trying to do. You are talking
about an Outlook profile that is configured to sync with multiple POP3
accounts, correct? It seems like you are inferring that each POP3 account
logically maps to a separate .PST file -- that is not the case. Mail from
all POP3 accounts is delivered to a single Inbox folder in a single .PST.

When you have multiple configured POP3 accounts you may choose which you
want to send from, when composing; by default the from address for a reply
is dictated by the account on which it was received (but it is still
user-selectable.)

If what you want to do is separate the items in Sent Items, according to the
POP3 account from which it was sent, I think you could get that by reading
the PR_SENDER_EMAIL_ADDRESS property (using extended MAPI or Redemption) and
move the item accordingly. But a separate destination corresponding to each
POP3 will not already exist, you'll have to create them yourself (presumably
as folders under Sent Items -- as a user I personally would be disenchanted
by an AddIn that created a bunch of .PST files like that.)


-Mark




"JHP" wrote in message
...
I've written a Macro that moves sent email to the proper Mailbox without
hard-coding Mailbox name; working great with Exchange Accounts, but if
this same approch is used with PST Accounts...

I don't know how (where to begin) to match the Sent mail to the correct
folder, as the folder name can be renamed and may not match the
SentOnBehalfOfName?

Thank you for any assistance,





  #4  
Old May 7th 09, 04:32 PM posted to microsoft.public.outlook.program_vba
JHP
external usenet poster
 
Posts: 8
Default Sent Items

Thank you for replying Mark McGinty,

Forgetting about the PST file - you have it right that I want to move the
sent items to the "proper" (SentOnBehalfOfName) account - but I want to
accomplish this as the items are being sent, and not have to hard-code the
folder name.

This is a very easy task if I wanted to hardcode the folder name, but as I
have stated in previous posts - I have already accomplished this in an
Exchange environment, but in a "PST" environment the user can change the
Account Name - making SentOnBehalfOfName useless.

Thank you for any insites,

"Mark McGinty" wrote in message
...

"JHP" wrote in message
...
Maybe I need supply more information?

I am trying to determine if a sent email (from address) belongs to an
existing (visible) mailbox...

Lets say I have multiple accounts (PST files as I already have Exchange
folders working) setup - I want to be able to determine which account the
email was sent from.

I don't want to have to hard-code the folder name (Select Case to match
address to folder) as a (PST) mailbox can be renamed.

I thought of using StoreID but a sent email (Parent.StoreID) takes on the
Default account's ID.

Any help would be greatly appreciated,


I'm still a little unclear as to what you're trying to do. You are
talking about an Outlook profile that is configured to sync with multiple
POP3 accounts, correct? It seems like you are inferring that each POP3
account logically maps to a separate .PST file -- that is not the case.
Mail from all POP3 accounts is delivered to a single Inbox folder in a
single .PST.

When you have multiple configured POP3 accounts you may choose which you
want to send from, when composing; by default the from address for a reply
is dictated by the account on which it was received (but it is still
user-selectable.)

If what you want to do is separate the items in Sent Items, according to
the POP3 account from which it was sent, I think you could get that by
reading the PR_SENDER_EMAIL_ADDRESS property (using extended MAPI or
Redemption) and move the item accordingly. But a separate destination
corresponding to each POP3 will not already exist, you'll have to create
them yourself (presumably as folders under Sent Items -- as a user I
personally would be disenchanted by an AddIn that created a bunch of .PST
files like that.)


-Mark




"JHP" wrote in message
...
I've written a Macro that moves sent email to the proper Mailbox without
hard-coding Mailbox name; working great with Exchange Accounts, but if
this same approch is used with PST Accounts...

I don't know how (where to begin) to match the Sent mail to the correct
folder, as the folder name can be renamed and may not match the
SentOnBehalfOfName?

Thank you for any assistance,







  #5  
Old May 7th 09, 08:23 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Sent Items

How exactly do you associate an SMTP account with the store? Do you set
where the messages will be delivered in Tools | Accounts?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"JHP" wrote in message
...
Thank you for replying Mark McGinty,

Forgetting about the PST file - you have it right that I want to move the
sent items to the "proper" (SentOnBehalfOfName) account - but I want to
accomplish this as the items are being sent, and not have to hard-code the
folder name.

This is a very easy task if I wanted to hardcode the folder name, but as I
have stated in previous posts - I have already accomplished this in an
Exchange environment, but in a "PST" environment the user can change the
Account Name - making SentOnBehalfOfName useless.

Thank you for any insites,

"Mark McGinty" wrote in message
...

"JHP" wrote in message
...
Maybe I need supply more information?

I am trying to determine if a sent email (from address) belongs to an
existing (visible) mailbox...

Lets say I have multiple accounts (PST files as I already have Exchange
folders working) setup - I want to be able to determine which account
the email was sent from.

I don't want to have to hard-code the folder name (Select Case to match
address to folder) as a (PST) mailbox can be renamed.

I thought of using StoreID but a sent email (Parent.StoreID) takes on
the Default account's ID.

Any help would be greatly appreciated,


I'm still a little unclear as to what you're trying to do. You are
talking about an Outlook profile that is configured to sync with multiple
POP3 accounts, correct? It seems like you are inferring that each POP3
account logically maps to a separate .PST file -- that is not the case.
Mail from all POP3 accounts is delivered to a single Inbox folder in a
single .PST.

When you have multiple configured POP3 accounts you may choose which you
want to send from, when composing; by default the from address for a
reply is dictated by the account on which it was received (but it is
still user-selectable.)

If what you want to do is separate the items in Sent Items, according to
the POP3 account from which it was sent, I think you could get that by
reading the PR_SENDER_EMAIL_ADDRESS property (using extended MAPI or
Redemption) and move the item accordingly. But a separate destination
corresponding to each POP3 will not already exist, you'll have to create
them yourself (presumably as folders under Sent Items -- as a user I
personally would be disenchanted by an AddIn that created a bunch of .PST
files like that.)


-Mark




"JHP" wrote in message
...
I've written a Macro that moves sent email to the proper Mailbox
without hard-coding Mailbox name; working great with Exchange Accounts,
but if this same approch is used with PST Accounts...

I don't know how (where to begin) to match the Sent mail to the correct
folder, as the folder name can be renamed and may not match the
SentOnBehalfOfName?

Thank you for any assistance,









  #6  
Old May 7th 09, 09:01 PM posted to microsoft.public.outlook.program_vba
JHP
external usenet poster
 
Posts: 8
Default Sent Items

Yes - under User Information - E-mail Address.

If you reverse the process... how does an incoming email know to go to a
particular folder (Account); I would like to know that logic and apply it
here.

When I send an email as someone else I want to move the mail item to the
correct Sent Items folder (if it exists in the current profile), but I don't
want to hard code the Folder Name to the Sender Name as the folder name may
change.

The following is what I did for our Exchange environment
(ThisOutlookSession):

Private WithEvents sentItems As Items

Private Sub Application_Startup()
Dim objNS As NameSpace
Dim objRecipient As Recipient
Dim objFolder As MAPIFolder

Set objNS = Me.GetNamespace("MAPI")
Set objRecipient = objNS.CreateRecipient(objNS.CurrentUser.Address)
objRecipient.Resolve

If objRecipient.Resolved Then
Set objFolder = objNS.GetDefaultFolder(olFolderSentMail)
Set sentItems = objFolder.Items
Set objFolder = Nothing
Else
MsgBox ("Error: Name Not Resolved - Please Contact Your
Administrator")
End If
Set objRecipient = Nothing
Set objNS = Nothing
End Sub

Private Sub sentItems_ItemAdd(ByVal Item As Object)
Dim objItem As Outlook.MailItem
Dim objNS As NameSpace
Const g_PR_SMTP_ADDRESS_W = &H39FE001F

If (TypeOf Item Is Outlook.MailItem) Then
Set objItem = Item
Set objNS = Me.GetNamespace("MAPI")

If objNS.CurrentUser.Name objItem.SentOnBehalfOfName And
objNS.CurrentUser.Name objNS.CurrentUser.Address Then
strEntryID = objItem.EntryID
strStoreID = objItem.Parent.StoreID
Set objSession = CreateObject("MAPI.Session")
objSession.Logon "", "", False, False
Set objMessage = objSession.GetMessage(strEntryID, strStoreID)
strAddress = objMessage.Sender.Address

If Not InStr(strAddress, "@") Then
On Error Resume Next
strAddress =
objMessage.Sender.Fields(g_PR_SMTP_ADDRESS_W).Valu e
End If
objSession.Logoff
Set objMessage = Nothing
Set objSession = Nothing
Set objFolders = objNS.Folders

For Each rtnFolder In objFolders
strMailbox = rtnFolder.Name

If strMailbox = "Mailbox - " & objItem.SentOnBehalfOfName
Then
Set objSentItems =
objNS.Folders(strMailbox).Folders("Sent Items")
objItem.Move objSentItems
Set objSentItems = Nothing
Exit For
End If
Next
Set objFolders = Nothing
End If
Set objNS = Nothing
Set objItem = Nothing
End If
End Sub

"Dmitry Streblechenko" wrote in message
...
How exactly do you associate an SMTP account with the store? Do you set
where the messages will be delivered in Tools | Accounts?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"JHP" wrote in message
...
Thank you for replying Mark McGinty,

Forgetting about the PST file - you have it right that I want to move the
sent items to the "proper" (SentOnBehalfOfName) account - but I want to
accomplish this as the items are being sent, and not have to hard-code
the folder name.

This is a very easy task if I wanted to hardcode the folder name, but as
I have stated in previous posts - I have already accomplished this in an
Exchange environment, but in a "PST" environment the user can change the
Account Name - making SentOnBehalfOfName useless.

Thank you for any insites,

"Mark McGinty" wrote in message
...

"JHP" wrote in message
...
Maybe I need supply more information?

I am trying to determine if a sent email (from address) belongs to an
existing (visible) mailbox...

Lets say I have multiple accounts (PST files as I already have Exchange
folders working) setup - I want to be able to determine which account
the email was sent from.

I don't want to have to hard-code the folder name (Select Case to match
address to folder) as a (PST) mailbox can be renamed.

I thought of using StoreID but a sent email (Parent.StoreID) takes on
the Default account's ID.

Any help would be greatly appreciated,

I'm still a little unclear as to what you're trying to do. You are
talking about an Outlook profile that is configured to sync with
multiple POP3 accounts, correct? It seems like you are inferring that
each POP3 account logically maps to a separate .PST file -- that is not
the case. Mail from all POP3 accounts is delivered to a single Inbox
folder in a single .PST.

When you have multiple configured POP3 accounts you may choose which you
want to send from, when composing; by default the from address for a
reply is dictated by the account on which it was received (but it is
still user-selectable.)

If what you want to do is separate the items in Sent Items, according to
the POP3 account from which it was sent, I think you could get that by
reading the PR_SENDER_EMAIL_ADDRESS property (using extended MAPI or
Redemption) and move the item accordingly. But a separate destination
corresponding to each POP3 will not already exist, you'll have to create
them yourself (presumably as folders under Sent Items -- as a user I
personally would be disenchanted by an AddIn that created a bunch of
.PST files like that.)


-Mark




"JHP" wrote in message
...
I've written a Macro that moves sent email to the proper Mailbox
without hard-coding Mailbox name; working great with Exchange
Accounts, but if this same approch is used with PST Accounts...

I don't know how (where to begin) to match the Sent mail to the
correct folder, as the folder name can be renamed and may not match
the SentOnBehalfOfName?

Thank you for any assistance,











  #7  
Old May 8th 09, 08:19 PM posted to microsoft.public.outlook.program_vba
JHP
external usenet poster
 
Posts: 8
Default Sent Items

Not sure if this thread has died - so this is another attempt for ideas -
Thank you,

RECAP:

- setup multiple (POP3 / IMAP) accounts in a PST file.
- send email as one the the viewable accounts (SendOnBehalfOfName), not as
the default user.
- move the sent item to the "correct" sent items folder - on the fly.

* I don't want to hardcode the folder names as they can be changed (unlike
Exchange Accounts).

I have supplied an example of my Exchange version in one of the previous
threads.

Thank you,


"JHP" wrote in message
...
I've written a Macro that moves sent email to the proper Mailbox without
hard-coding Mailbox name; working great with Exchange Accounts, but if
this same approch is used with PST Accounts...

I don't know how (where to begin) to match the Sent mail to the correct
folder, as the folder name can be renamed and may not match the
SentOnBehalfOfName?

Thank you for any assistance,



 




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
delete button doesn't move items to deleted items folder Anne Outlook - Installation 4 April 16th 09 02:46 PM
how to retain 10 days items in Outlook 2003 deleted items folder? Balthazar Outlook - Installation 2 June 7th 06 04:05 PM
Auto Empty Deleted Items on Exit OR after X days or X Items accumulated? JDJ Outlook - General Queries 2 May 30th 06 10:48 PM
Reading mails from Sent items, Deleted items, Draft folder of outlook from VB6.0 Viswanathan Outlook - General Queries 8 May 26th 06 04:31 PM
Inbox, Sent Items & Outbox in Deleted Items in Outlook 2003 & OWA with Exchange splounx Outlook - General Queries 1 February 17th 06 02:22 AM


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