[RESOLVED] Parsing SenderEmailAddress on incoming Items in Outlook 2003
I am trying to create some VBcode in Outlook 2003 that will inspect the SenderEmailAddress and route the email to the appropriate sub folder. As an example to this problem if an incoming email came from the SenderEmailAddress [email protected] I want to move all email from the domain of "@yahoo.com" to the sub folder of my inbox named Yahoo Mail. In trying to do this I ran into a problem where I am getting an error 424 object required. Is there another way to accomplish what I am looking to do? Any help would be greatly appreciated, here is what I have so far:
VB Code:
Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
Dim objNS As NameSpace
Dim objInbox As MAPIFolder
Dim objMoveFolder As MAPIFolder
Dim intDomainNameStart As Integer
Dim strUserName As String
Dim strDomainName As String
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
'--Sort by SenderEmailAddress--
intDomainNameStart = Item.SenderEmailAddress.IndexOf("@") 'I get the 424 Error Here
Re: Parsing SenderEmailAddress on incoming Items in Outlook 2003
I do know that but I have many more rules than just the one in the example that exceed the 32k limit on rules allowed. So I am trying to get around that by simulating the rules wizard through VBCode.
BTW the InStr function worked on that first line and now I am getting the same error for the subsequent two lines.
Re: Parsing SenderEmailAddress on incoming Items in Outlook 2003
OK, so code is the way to go.
You are getting errors on the next two lines because of Substring, which is not a vba Function
I would suggest using the vba function "Mid" to get the domain and "Left" to get the UserName.
Re: Parsing SenderEmailAddress on incoming Items in Outlook 2003
DKenny,
That last bit of code did not fix the problem it gave me this error "outlook run-time error 438" Object does not support that method. The code may not have worked but it set me on the right path to fix the code. I change the code so that the parsing looks like this:
Re: Parsing SenderEmailAddress on incoming Items in Outlook 2003
Not a probnlem, just glad you were able to sort it now. Please don't forget to mark this thread as resolved (its under Thead tools at the top of the page).
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful