"This item contains active content that cannot..." Workaround?

"This item contains active content that cannot..." Workaround?

Post by methodman » Thu, 02 Mar 2006 03:24:35


I have a custom form and the recipient can't see the message in the
preview pane. I know this is normal since my custom form has code
behind it. The recipient doesn't need to have the form information so
I tried sending a new message in the Item_Send event. I also have the
"Send form definition with item" box unchecked. Here's my code that I
saw posted in these forums a while ago that worked for someone, but
apparently not for me. I'm using Outlook2003, XP SP2. The code
doesn't throw any errors, but the message still can't be previewed.
What am I doing wrong? Thanks!

Function Item_Send()

Dim objInspector
Dim objMessage
Dim objMailItemCopy

Set objInspector = Application.ActiveInspector
Set objMessage = objInspector.CurrentItem
Set objMailItemCopy = objMessage.Copy
objMailItemCopy.MessageClass = "IPM.Note"
objMailItemCopy.Send

Item_Send = False

Set objInsp = Item.GetInspector
objInsp.Close 1

End Function
 
 
 

"This item contains active content that cannot..." Workaround?

Post by Sue Mosher » Thu, 02 Mar 2006 03:36:43

Because you copied the message instead of creating a new one, it still has the "active content." The way to make this work is to create an entirely new message with Application.CreateItem and then copy the property values and recipients from the old message into the new message.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.yqcomputer.com/
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.yqcomputer.com/

 
 
 

"This item contains active content that cannot..." Workaround?

Post by methodman » Thu, 02 Mar 2006 04:24:23

Something like this? I get a message box saying it was attempting to
send a message (which I would like to supress) and still didn't work in
the preview pane. Can you help me out with the code?

Function Item_Send()
Set objOutlook = CreateObject("Outlook.Application")
Set objInspector = objOutlook.ActiveInspector
Set objMessage = objInspector.CurrentItem
Set objMailItemCopy = objMessage.Copy
objMailItemCopy.MessageClass = "IPM.Note"
objMailItemCopy.Send

Item_Send = False

Set objInsp = Item.GetInspector
objInsp.Close 1
End Function
 
 
 

"This item contains active content that cannot..." Workaround?

Post by Sue Mosher » Thu, 02 Mar 2006 04:40:01

Outlook version?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.yqcomputer.com/
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.yqcomputer.com/
 
 
 

"This item contains active content that cannot..." Workaround?

Post by methodman » Thu, 02 Mar 2006 04:52:36

OL2003 on XP SP2.

This code seems closer, but I'm not sure how to access the fields other
than Body and Message.

Set objInspector = Application.ActiveInspector
Set objMessage = objInspector.CurrentItem
Set objMailItem = Application.CreateItem(0)
objMailItem.Body = objMessage.Body
objMailItem.Subject = objMessage.Subject
objMailItem.MessageClass = "IPM.Note"
objMailItem.Send
 
 
 

"This item contains active content that cannot..." Workaround?

Post by Sue Mosher » Thu, 02 Mar 2006 05:13:06

There is no need to work with an Inspector. The item where the code is running is represented by the Item object, thus:

Set objMailItem = Application.CreateItem(0)
objMailItem.Body = Item.Body
objMailItem.Subject = Item.Subject
For each recip in Item.Recipients
objMailItem.Recipients.Add recip.address
Next
objMailItem.Send

You don't need to set the MessageClass property, since a new message created with CreateItem is always IPM.Note.

See http://www.yqcomputer.com/ , so you must loop through it and get each Recipient's Address property.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.yqcomputer.com/
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.yqcomputer.com/
 
 
 

"This item contains active content that cannot..." Workaround?

Post by methodman » Thu, 02 Mar 2006 05:29:46

Genius!

The only other thing I need to do is copy the attachments (if any).
I'm trying to use the CopyAttachments(objSourceItem As Object,
objTargetItem As Object) function you wrote that is in the book online.
When I try this I get the runtime error: Expted ')' for the line of
the Sub CopyAttachments(objSourceItem As Object, objTargetItem As
Object). What is going on here?

When this works, all I will need to do is call this function as
CopyAttachments(Item,objMailItem) and the new e-mail will look exactly
like the form one right (minus the custom form elements of course)?

Thanks for all your help! I'm very close now!
 
 
 

"This item contains active content that cannot..." Workaround?

Post by Sue Mosher » Thu, 02 Mar 2006 05:35:43

That procedure is for VBA, not VBScript, which doesn't support typed variable declarations. For a cutdown VBScript version, see http://www.yqcomputer.com/ (It doesn't have FileExists checking of the version in the book.)

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.yqcomputer.com/
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.yqcomputer.com/
 
 
 

"This item contains active content that cannot..." Workaround?

Post by methodman » Thu, 02 Mar 2006 06:14:36

That makes sense. It's all working now. Thank you very much for all
your help. You're clearly the guru of all things Outlook programming.
I hope someone finds our exchange helpful. Thanks again!