Geo123
asked on
Outlook VBA or Access to look through all messages in folder
HI all
Have been tasked with fixing an overflowing inbox in outlook. Need routine to debug print all Folders/ mailboxes. Just out put names
Then next part is routine to access 1 of boxes above and go through all email items....... in Inbox
Look at email address or for word Account in Subject or body........
That should be enough for now
Am going to do link to access data to match Email or account no
cheers
George
Have been tasked with fixing an overflowing inbox in outlook. Need routine to debug print all Folders/ mailboxes. Just out put names
Then next part is routine to access 1 of boxes above and go through all email items....... in Inbox
Look at email address or for word Account in Subject or body........
That should be enough for now
Am going to do link to access data to match Email or account no
cheers
George
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
HI stefri.... I put that code in and got runtime error 424, object required
For this line Set myFolders = objNS.Folders
I notice there is no dim' ing of objNS... is this the namespace???
cheers
George
For this line Set myFolders = objNS.Folders
I notice there is no dim' ing of objNS... is this the namespace???
cheers
George
Sorry, you are right
Dim objNS as Outlook.Namespace (global scope)
It is part of a code I modified apparently a little to fast
Stefri
Dim objNS as Outlook.Namespace (global scope)
It is part of a code I modified apparently a little to fast
Stefri
ASKER
ok Stefri that appears to be running...how do I loop through all emails in in box????
myshared is the Inbox of the sharedmailbox you want to monitor
dim itm as variant
for each itm in myShared.Items
' dowhatever you want with itm which represents a mail, a meeting request, a task assignment...etc.
next
Stefri
dim itm as variant
for each itm in myShared.Items
' dowhatever you want with itm which represents a mail, a meeting request, a task assignment...etc.
next
Stefri
ASKER
cool Stefri.... thats working as I loop through mailbox I get the mail items.
I would like to move each email as the routine processes them....how do I do this???
cheers
George
I would like to move each email as the routine processes them....how do I do this???
cheers
George
Moves an Outlook item to a new folder.
expression.Move(DestFldr)
expression Required. An expression that returns one of the objects in the Applies To list.
DestFldr Required. An expression that returns a MAPIFolder object. The destination folder.
In your case:
for each itm in myShared.Items
itm.move DestFldr
next
In VBA, check View/Object Viewer where you get inline help
Stefri
expression.Move(DestFldr)
expression Required. An expression that returns one of the objects in the Applies To list.
DestFldr Required. An expression that returns a MAPIFolder object. The destination folder.
In your case:
for each itm in myShared.Items
itm.move DestFldr
next
In VBA, check View/Object Viewer where you get inline help
Stefri
ASKER
ok stefri.... will test that. it was outwith scope of my question so will add some points
ASKER
ok Stefri this is doing me heed in....... am creating a reply to email I process...... what property do i get email address from ??
Have done this before using myItem.ReplyRecipients.Ite m(1).Addre ss....its not playing now..... am in Outlook 2000
cheers
George
Have done this before using myItem.ReplyRecipients.Ite
cheers
George
ASKER
Stefri...further woes..... it appears in outlook if email I get in has J Smith [some@email.co.uk] then SenderName gives just J Smith.....how do I get to email??
I prepare reply (myitem.reply). If its just George@aol.com then thats fine
also when I goto move email that been dealt with to folder processed myItem.Move "Processed", it cant find it...... think its looking in my mailbox folders and not attached Mailbox- Online
Then when I sent the email it sends from my email box with mt sender name on it and puts it in Sent Items, not the online Sent Items.
What u reckon???
cheers Geo
I prepare reply (myitem.reply). If its just George@aol.com then thats fine
also when I goto move email that been dealt with to folder processed myItem.Move "Processed", it cant find it...... think its looking in my mailbox folders and not attached Mailbox- Online
Then when I sent the email it sends from my email box with mt sender name on it and puts it in Sent Items, not the online Sent Items.
What u reckon???
cheers Geo
If you reply a mail, by default it will use the reply addres which is in the mail: so no need to specify one
SenderName is the visible part of email address, you cant use this property
If you need the email address itself, you will need extra soft (redemption.dll) to avoid security warning
if you want to move to a folder not in your default profile but from the sahred mailbox, you have to use the Folders propertiy of myshared (which is Inbox folder)
if you want to get the parent of this inbox
myshared.Parent
subfoders at same level as this inbox
myshared.Parent.folders
sub folders of this inbox
myshared.Folders
Check Folders property in VBA help
>>>>>Then when I sent the email it sends from my email box with mt sender name on it and puts it in Sent Items, not the online Sent Items.
It is the standard behaviour
stefri
SenderName is the visible part of email address, you cant use this property
If you need the email address itself, you will need extra soft (redemption.dll) to avoid security warning
if you want to move to a folder not in your default profile but from the sahred mailbox, you have to use the Folders propertiy of myshared (which is Inbox folder)
if you want to get the parent of this inbox
myshared.Parent
subfoders at same level as this inbox
myshared.Parent.folders
sub folders of this inbox
myshared.Folders
Check Folders property in VBA help
>>>>>Then when I sent the email it sends from my email box with mt sender name on it and puts it in Sent Items, not the online Sent Items.
It is the standard behaviour
stefri
ASKER
> If you reply a mail, by default it will use the reply addres which is in the mail: so no need to specify one
how?
>If you need the email address itself, you will need extra soft (redemption.dll) to avoid security warning
if you want to move to a folder not in your default profile but from the sahred mailbox, you have to use the Folders propertiy of myshared (which is Inbox folder)
if you want to get the parent of this inbox
myshared.Parent
subfoders at same level as this inbox
myshared.Parent.folders
sub folders of this inbox
myshared.Folders
Check Folders property in VBA help
>>>>>Then when I sent the email it sends from my email box with mt sender name on it and puts it in Sent Items, not the online Sent Items.
It is the standard behaviour
how?
>If you need the email address itself, you will need extra soft (redemption.dll) to avoid security warning
if you want to move to a folder not in your default profile but from the sahred mailbox, you have to use the Folders propertiy of myshared (which is Inbox folder)
if you want to get the parent of this inbox
myshared.Parent
subfoders at same level as this inbox
myshared.Parent.folders
sub folders of this inbox
myshared.Folders
Check Folders property in VBA help
>>>>>Then when I sent the email it sends from my email box with mt sender name on it and puts it in Sent Items, not the online Sent Items.
It is the standard behaviour
ASKER
> If you reply a mail, by default it will use the reply addres which is in the mail: so no need to specify one
how?
>If you need the email address itself, you will need extra soft (redemption.dll) to avoid security warning
I have no idea how to do this
if you want to move to a folder not in your default profile but from the sahred mailbox, you have to use the Folders propertiy of myshared (which is Inbox folder)
if you want to get the parent of this inbox
myshared.Parent
subfoders at same level as this inbox
myshared.Parent.folders
sub folders of this inbox
myshared.Folders
Check Folders property in VBA help
ok will try this
>>>>>Then when I sent the email it sends from my email box with mt sender name on it and puts it in Sent Items, not the online Sent Items.
It is the standard behaviour
......ok
I am not very good at Outlook coding...not done much of it........ deffo need to have email as I use it to look up customer in database and amend there record with the email. I will up points to 500 if u solve these issues for me.......... how can u resisit 500 Stefri!!!!
Need it to finish of piece of work.... becoming urgent
cheers
George
how?
>If you need the email address itself, you will need extra soft (redemption.dll) to avoid security warning
I have no idea how to do this
if you want to move to a folder not in your default profile but from the sahred mailbox, you have to use the Folders propertiy of myshared (which is Inbox folder)
if you want to get the parent of this inbox
myshared.Parent
subfoders at same level as this inbox
myshared.Parent.folders
sub folders of this inbox
myshared.Folders
Check Folders property in VBA help
ok will try this
>>>>>Then when I sent the email it sends from my email box with mt sender name on it and puts it in Sent Items, not the online Sent Items.
It is the standard behaviour
......ok
I am not very good at Outlook coding...not done much of it........ deffo need to have email as I use it to look up customer in database and amend there record with the email. I will up points to 500 if u solve these issues for me.......... how can u resisit 500 Stefri!!!!
Need it to finish of piece of work.... becoming urgent
cheers
George
Let' say you are foreach'ing itm in the myShared.Items
To reply: itm.Reply or itm.ReplyAll should be preadressed to the sender
Redemption is avalaible at http://www.dimastr.com/redemption/, it bypasses MS security if you use what they call a safeitem
Install it.
then
dim SafeItem, oItem
dim itm as variant
for each itm in myShared.Items
set SafeItem = CreateObject("Redemption.S afeMailIte m") 'Create an instance of Redemption.SafeMailItem
set oItem = itm.ReplyAll
SafeItem.Item = oItem 'set Item property
SafeItem.Send
set SafeItem = Nothing
next
How do you look up your customer? Which info is used? Email Address, Name
If Email Address from a received mail:
dim senderAddress as string
dim SafeItem, oItem
dim PrSenderEmail as Long
PrSenderEmail = &H0C1F001E
dim itm as variant
for each itm in myShared.Items
set SafeItem = CreateObject("Redemption.S afeMailIte m") 'Create an instance of Redemption.SafeMailItem
set oItem = itm
SafeItem.Item = oItem 'set Item property
senderAddress = SafeItem.Fields(PrSenderEm ail)
set SafeItem = Nothing
next
Should do the trick
Stefri
PS: I am not related to dimastr but it is a wonderful tool which is free on top of that!!!
To reply: itm.Reply or itm.ReplyAll should be preadressed to the sender
Redemption is avalaible at http://www.dimastr.com/redemption/, it bypasses MS security if you use what they call a safeitem
Install it.
then
dim SafeItem, oItem
dim itm as variant
for each itm in myShared.Items
set SafeItem = CreateObject("Redemption.S
set oItem = itm.ReplyAll
SafeItem.Item = oItem 'set Item property
SafeItem.Send
set SafeItem = Nothing
next
How do you look up your customer? Which info is used? Email Address, Name
If Email Address from a received mail:
dim senderAddress as string
dim SafeItem, oItem
dim PrSenderEmail as Long
PrSenderEmail = &H0C1F001E
dim itm as variant
for each itm in myShared.Items
set SafeItem = CreateObject("Redemption.S
set oItem = itm
SafeItem.Item = oItem 'set Item property
senderAddress = SafeItem.Fields(PrSenderEm
set SafeItem = Nothing
next
Should do the trick
Stefri
PS: I am not related to dimastr but it is a wonderful tool which is free on top of that!!!
ASKER
Stefri.... mind I have Nal'ed PCs (Or rather my users do) if this redemption needs installed it may pose a problem!!!!
Ow god do I have to buy it...groan...red tape!!!!
Will try it but nal and buying part will stuff me i think
Ow god do I have to buy it...groan...red tape!!!!
Will try it but nal and buying part will stuff me i think
deplying Redemtion shold be done with a Netlogon, I think
If you do not want to install, you users will have to click yes when the security popup is displayed
you do not need to buy: it is a real freeware, you only pay if yo need he dll in a software to be sold.
stefri
If you do not want to install, you users will have to click yes when the security popup is displayed
you do not need to buy: it is a real freeware, you only pay if yo need he dll in a software to be sold.
stefri
ASKER
If the user doesnt insatl Redemption...they can still get Sender email?
Tricky to get
Sub testSend()
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Set myOlExp = Application.ActiveExplorer
Set myOlSel = myOlExp.Selection
On Error Resume Next
If myOlSel.Count > 0 Then
Dim oRep As Outlook.MailItem
Set oRep = myOlSel.Item(1).Reply
Dim recip As Outlook.Recipient
For Each recip In oRep.Recipients ' GENERATES A SECURITY WARNING avoided with redemption and code as provided in previous post
MsgBox "To: " & recip.Address
Next
Set recip = Nothing
oRep.Close False
Set oRep = Nothing
End If
Set myOlExp = Nothing
Set myOlSel = Nothing
End Sub
stefri
PS: tested on OL2002
Sub testSend()
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Set myOlExp = Application.ActiveExplorer
Set myOlSel = myOlExp.Selection
On Error Resume Next
If myOlSel.Count > 0 Then
Dim oRep As Outlook.MailItem
Set oRep = myOlSel.Item(1).Reply
Dim recip As Outlook.Recipient
For Each recip In oRep.Recipients ' GENERATES A SECURITY WARNING avoided with redemption and code as provided in previous post
MsgBox "To: " & recip.Address
Next
Set recip = Nothing
oRep.Close False
Set oRep = Nothing
End If
Set myOlExp = Nothing
Set myOlSel = Nothing
End Sub
stefri
PS: tested on OL2002
ASKER
ok will try this.... running on Outlook 2000
cheers
George
cheers
George
ASKER
If I use myNameSpace.CurrentUser.Na
So how do I change to Mailbox - Online ??????
cheers
George