Googleplexity
Programmer
Basically to make a long story short this project is giving me grey hair fast with strange errors at every turn. Even on the most simple of tasks. I've recreated several forms using Infopath 2007. These forms are sent thru, and received in Outlook 2007. I have a rule in OL07 that will kick off a pretty simple script that will take the email, copy out attactments, and the infopath form body ([Copy Full Body from Sue Mosher][1]) into a new Task item. Depending on the answers I get for this question then I'll ask several others. But right now this is my problem:
I receive a new email. Rule kicks in and the script takes over, if I have no watches in place I get the body from the next most recent email in my inbox. If my inbox is empty I get no body at all. If step through the code it goes off without a hitch. I know the correct OL object is being passed to the copy full body routine but I'm not familiar enough with object models of either outlook or word to know where things are failing. Here is Sue's code:
I need this to grab the body from the incoming email (I pass that object in another bit of code). But it seems to be getting the body either of the next most recent, or it just occured to me, the mailitem that is selected.
If you all have any advice I'd be very appreciative, or have any questions, I'll answer as soon as I can.
Thanks.
I receive a new email. Rule kicks in and the script takes over, if I have no watches in place I get the body from the next most recent email in my inbox. If my inbox is empty I get no body at all. If step through the code it goes off without a hitch. I know the correct OL object is being passed to the copy full body routine but I'm not familiar enough with object models of either outlook or word to know where things are failing. Here is Sue's code:
Code:
Sub CopyFullBody(sourceItem As Object, targetItem As Object)
Dim objDoc As Word.Document
Dim objSel As Word.Selection
Dim objDoc2 As Word.Document
Dim objSel2 As Word.Selection
On Error Resume Next
' get a Word.Selection from the source item
Set objDoc = sourceItem.GetInspector.WordEditor
If Not objDoc Is Nothing Then
Set objSel = objDoc.Windows(1).Selection
objSel.WholeStory
objSel.Copy
Set objDoc2 = targetItem.GetInspector.WordEditor
If Not objDoc2 Is Nothing Then
Set objSel2 = objDoc2.Windows(1).Selection
objSel2.PasteAndFormat wdPasteDefault
Else
MsgBox "Could not get Word.Document for " & _
targetItem.Subject
End If
Else
MsgBox "Could not get Word.Document for " & _
sourceItem.Subject
End If
Set objDoc = Nothing
Set objSel = Nothing
Set objDoc2 = Nothing
Set objSel2 = Nothing
End Sub
I need this to grab the body from the incoming email (I pass that object in another bit of code). But it seems to be getting the body either of the next most recent, or it just occured to me, the mailitem that is selected.
If you all have any advice I'd be very appreciative, or have any questions, I'll answer as soon as I can.
Thanks.