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,
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" <J...@goawayplease.com> wrote in message
news:eaHz9hPz...@TK2MSFTNGP06.phx.gbl...
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
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" <mmcg...@spamfromyou.com> wrote in message
news:eaIHP5oz...@TK2MSFTNGP05.phx.gbl...
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"JHP" <J...@goawayplease.com> wrote in message
news:OOExhjyz...@TK2MSFTNGP06.phx.gbl...
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).Value
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" <dmi...@dimastr.com> wrote in message
news:uE1Qzn0z...@TK2MSFTNGP02.phx.gbl...
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" <J...@goawayplease.com> wrote in message
news:eaHz9hPz...@TK2MSFTNGP06.phx.gbl...
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"JHP" <J...@goawayplease.com> wrote in message
news:OhF8N60z...@TK2MSFTNGP04.phx.gbl...
Again thank you for your expertise, I really appreciate you taking the time
here... really!
Is it possible to access that information the way Outlook does (POP3/SMTP)
via script?
I really like the idea of using the GAL - thank you.
"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message
news:eHJ1EVb0...@TK2MSFTNGP05.phx.gbl...
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"JHP" <J...@goawayplease.com> wrote in message
news:%23fK3oGZ...@TK2MSFTNGP04.phx.gbl...
So the short answer is POP3/SMTP.
Thank you (hope I haven't left this to long?),
"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message
news:%239KjdNm...@TK2MSFTNGP06.phx.gbl...
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"JHP" <J...@goawayplease.com> wrote in message
news:u7L0XfX2...@TK2MSFTNGP04.phx.gbl...
"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message
news:OHbgLYI3...@TK2MSFTNGP06.phx.gbl...