Trying to copy and forward MailItem fails

P

Paul

I have a custom form set to a specific message class. The form has a
button to forward the message. When the message is forwarded I want to
send it as a normal IPM.Note. To do that the button copies the item
and changes the message class in the code below.

Everything seems to be fine until I get to the copyItem.Display
statement. It executes with an Err.Number of 0 but no Inspector
displays. That statement is just there for debug purposes but I'm
curious as to why nothing is displayed.

The Set forwardItem = copyItem.Forward statement always fails with an
error code of -2147467260. I've tried moving the Item.Close(1) command
to the end of the function but the results are the same.

Any ideas as to why it is failing or how I can fix it will be
appreciated.

Function ForwardButton_Click()
Set copyItem = Item.Copy
copyItem.MessageClass = "IPM.Note"
copyItem.Save
eID = copyItem.EntryID
storeID = copyItem.Parent.StoreID
Set copyItem = Nothing
Set nameSpace = Item.Application.GetNamespace("MAPI")
Set copyItem = nameSpace.GetItemFromID(eID, storeID)
Item.Close(1)
copyItem.Display
If Err.Number <> 0 Then
MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description)
End If
Set forwardItem = copyItem.Forward
If Err.Number <> 0 Then
MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description)
End If
forwardItem.Display
Set nameSpace = Nothing
Set forwardItem = Nothing
copyItem.Delete
Set copyItem = Nothing
End Function

Thanks,
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top