ImagineTNT
11-14-2008, 11:50 AM
Hi, this is my first post :)
I am somewhat new to VBA so hope this isn't too basic a question but I have spent lots of time learning things searching this site and Google but still can't find the answer to this question:
I would like to pass a MailItem to a sub so I can modify its contents. I keep getting a "Run-time error '424': Object required" My call is in here:
Dim copyFromEmail As outlook.MailItem
Dim newEmail As outlook.MailItem
For Each copyFromEmail In emailCollection
Set newEmail = Application.CreateItem(olMailItem)
Set newEmail = copyFromEmail.copy
newEmail.UnRead = True
newEmail.Move clientLocation
'Change out template data with Implementation Data
replaceTemplateData (newEmail) ' ***** Error occurs here ********
Next copyFromEmail
And my subroutine setup is like this:
Public Sub replaceTemplateData(email As outlook.MailItem)
End Sub
Any help would be greatly appreciated,
Reuben
ps - ohhh, my loop takes emails stored in a collection and "saves" them to a folder in Outlook. It seems like a clunky way to do this so if anyone has suggestions I'm open to those as well. Thanks!!
I am somewhat new to VBA so hope this isn't too basic a question but I have spent lots of time learning things searching this site and Google but still can't find the answer to this question:
I would like to pass a MailItem to a sub so I can modify its contents. I keep getting a "Run-time error '424': Object required" My call is in here:
Dim copyFromEmail As outlook.MailItem
Dim newEmail As outlook.MailItem
For Each copyFromEmail In emailCollection
Set newEmail = Application.CreateItem(olMailItem)
Set newEmail = copyFromEmail.copy
newEmail.UnRead = True
newEmail.Move clientLocation
'Change out template data with Implementation Data
replaceTemplateData (newEmail) ' ***** Error occurs here ********
Next copyFromEmail
And my subroutine setup is like this:
Public Sub replaceTemplateData(email As outlook.MailItem)
End Sub
Any help would be greatly appreciated,
Reuben
ps - ohhh, my loop takes emails stored in a collection and "saves" them to a folder in Outlook. It seems like a clunky way to do this so if anyone has suggestions I'm open to those as well. Thanks!!