Item.Copy in Item_Send causes loop untill crash

R

rowan

I've seen quite a few posts on this exact issue, but I don't see any
where there were resolved. And any that do seem to have an answer, the
answer didn't work for me.
I've got a modified Message to track a request for service. It is
forwarded to the next responsible party. I want to send a copy of the
form to a public folder (in this testing phase a folder in my PST
file.) The problem is that when I do a copy in the Item_Send event it
processes the code in the newly created form and then somehow creates
another form and another until it crashes. Here is my entire code for
the form. Only two tabs, Message and History.

***********************************
Dim dontProcess
dontProcess = True
Dim savePath
savePath = "OUTLOOK RFS/Main Folder"
Dim msgClass
msgClass = "IPM.Note.IT Request For Serv"
Dim mainLabel
mainLabel = "Information Technology - Request for Service " & _
"and Tracking for Sarbanes-Oxley Act of 2002"

' Form Resizing overrides users defaulted or previous form size
Const wndrWidth = 775
Const wndrHeight = 620
Const olDiscard = 1


Function Item_CustomPropertyChange(myPropName)
'MsgBox "prop " & myPropName
'If Item.Size = 0 Then Exit Function
Dim retVal
retVal = False
If dontProcess Then Exit Function
Select Case myPropName
Case "chkIT"
ProcCheck myPropName, "AuthorizedIT", "AuthorizedITDate"
retVal = True
Case "chkBU"
ProcCheck myPropName, "AuthorizedBU", "AuthorizedBUDate"
retVal = True
Case "chkChanged"
ProcCheck myPropName, "AuthorizedChanged", "AuthorizedChangedDate"
retVal = True
Case "chkTested"
ProcCheck myPropName, "AuthorizedTested", "AuthorizedTestedDate"
retVal = True
Case "chkReview"
ProcCheck myPropName, "AuthorizedReview", "AuthorizedReviewDate"
retVal = True
Case "chkRequester"
ProcCheck myPropName, "AuthorizedRequester",
"AuthorizedRequesterDate"
retVal = True
Case "chkImplent"
ProcCheck myPropName, "AuthorizedImplent", "AuthorizedImplentDate"
retVal = True
Case "chkGranted"
ProcCheck myPropName, "AuthorizedGranted", "AuthorizedGrantedDate"
retVal = True
Case "chkUpdated"
ProcCheck myPropName, "AuthorizedUpdated", "AuthorizedUpdatedDate"
retVal = True
Case "chkRevoked"
ProcCheck myPropName, "AuthorizedRevoked", "AuthorizedRevokedDate"
retVal = True
Case "chkSent"
ProcCheck myPropName, "AuthorizedSent", "AuthorizedSentDate"
retVal = True
Case "chkClosed"
ProcCheck myPropName, "AuthorizedClosed", "AuthorizedClosedDate"
retVal = True
End Select
Item_CustomPropertyChange = retVal
End Function

Sub NABU_Click()
NAPress "chkBU","NABU","AuthorizedBU","AuthorizedBUDate"
End Sub
Sub NAIT_Click()
NAPress "chkIT","NAIT","AuthorizedIT","AuthorizedITDate"
End Sub
Sub NAChanged_Click()
NAPress
"chkChanged","NAChanged","AuthorizedChanged","AuthorizedChangedDate"
End Sub
Sub NATested_Click()
NAPress
"chkTested","NATested","AuthorizedTested","AuthorizedTestedDate"
End Sub
Sub NAReview_Click()
NAPress
"chkReview","NAReview","AuthorizedReview","AuthorizedReviewDate"
End Sub
Sub NARequester_Click()
NAPress
"chkRequester","NARequester","AuthorizedRequester","AuthorizedRequesterDate"
End Sub
Sub NAImplent_Click()
NAPress
"chkImplent","NAImplent","AuthorizedImplent","AuthorizedImplentDate"
End Sub
Sub NAGranted_Click()
NAPress
"chkGranted","NAGranted","AuthorizedGranted","AuthorizedGrantedDate"
End Sub
Sub NARevoked_Click()
NAPress
"chkRevoked","NARevoked","AuthorizedRevoked","AuthorizedRevokedDate"
End Sub
Sub NAUpdated_Click()
NAPress
"chkUpdated","NAUpdated","AuthorizedUpdated","AuthorizedUpdatedDate"
End Sub
Sub NASent_Click()
NAPress "chkSent","NASent","AuthorizedSent","AuthorizedSentDate"
End Sub
Sub NAClosed_Click()
NAPress
"chkClosed","NAClosed","AuthorizedClosed","AuthorizedClosedDate"
End Sub

Function NAPress(sCntrl,sBtn,sName,sDate)
Dim sStr
dontProcess = True
Set myinspector = Item.GetInspector
Set myPage1 = myInspector.ModifiedFormPages("Message")
Set chkB= myPage1.Controls(sCntrl)
Set btnB= myPage1.Controls(sBtn)
sStr = "lbl" & Mid(sCntrl,4, (Len(sCntrl) - 3))
Set lblClr = myPage1.Controls(sStr)

If btnB.Caption = "N/A" Then
chkB.Value = "True"
'chkB.Enabled = false
'ClearData sCntrl, sName, sDate
btnB.Caption = "--"
FillData sCntrl, sName, sDate
chkB.Enabled = false
lblClr.ForeColor = 6316128
Item.UserProperties(sBtn) = "True"
Else
chkB.Value = "False"
chkB.Enabled = true
ClearData sCntrl, sName, sDate
btnB.Caption = "N/A"
lblClr.ForeColor = 16711680
Item.UserProperties(sBtn) = "False"
End If
Set btnB = Nothing
Set chkB = Nothing
Set myPage1 = Nothing
Set myinspector = Nothing
Set lblClr = Nothing
dontProcess = False
End Function
Function ProcCheck(sCntrl,sName,sDate)
Set myinspector = Item.GetInspector
Set myPage1 = myInspector.ModifiedFormPages("Message")
Set auth= myPage1.Controls(sCntrl)
If auth.Value = "True" Then
FillData sCntrl, sName, sDate
Else
ClearData sCntrl, sName, sDate
End If
Set auth = Nothing
Set myPage1 = Nothing
Set myinspector = Nothing
End Function

Function FillData(sCntrl,sName,sDate)
Dim sUser
Dim sHist
Dim sStr
Set WshNetwork = CreateObject("WScript.Network")
sUser = WshNetwork.UserName
Set myinspector = Item.GetInspector
Set myPage1 = myInspector.ModifiedFormPages("Message")
Set myPage2 = myInspector.ModifiedFormPages("History")
Set chkBx = myPage1.Controls(sCntrl)
Set authBU= myPage1.Controls(sName)
Set authBUD= myPage1.Controls(sDate)
Set history = myPage2.Controls("History")
sStr = "NA" & Mid(sCntrl,4, (Len(sCntrl) - 3))
Set btnNA = myPage1.Controls(sStr)
authBU.ReadOnly = false
authBUD.ReadOnly = false
history.ReadOnly = false
'authBU.Value = Application.GetNameSpace("MAPI").CurrentUser
authBU.Value = sUser
'Item.UserProperties(sName) =
Application.GetNameSpace("MAPI").CurrentUser
Item.UserProperties(sName) = sUser
authBUD.Value = Now
Item.UserProperties(sDate) = Now
Item.UserProperties(sCntrl) = chkBx.Value
sHist = authBU.Value & " " & authBUD.Value
If btnNA.Caption = "N/A" Then
sHist = sHist & " checked:"
Else
sHist = sHist & " NA Click:"
End If
sHist = sHist & sName & Chr(13) & Chr(13) &
Item.UserProperties("History")
Item.UserProperties("History") = sHist
authBU.ReadOnly = true
authBUD.ReadOnly = true
history.ReadOnly = true
Set btnNA = Nothing
Set history = Nothing
Set authBUD = Nothing
Set authBU = Nothing
Set myPage1 = Nothing
Set myPage2 = Nothing
Set myinspector = Nothing
Set WshNetwork = Nothing
End Function
Function ClearData(sCntrl,sName,sDate)
Dim sHist
Set myinspector = Item.GetInspector
Set myPage1 = myInspector.ModifiedFormPages("Message")
Set myPage2 = myInspector.ModifiedFormPages("History")
Set chkBx = myPage1.Controls(sCntrl)
Set authBU= myPage1.Controls(sName)
Set authBUD= myPage1.Controls(sDate)
Set history = myPage2.Controls("History")
sStr = "NA" & Mid(sCntrl,4, (Len(sCntrl) - 3))
Set btnNA = myPage1.Controls(sStr)
authBU.ReadOnly = false
authBUD.ReadOnly = false
history.ReadOnly = false
sHist = authBU.Value & " " & authBUD.Value
If btnNA.Caption = "N/A" Then
sHist = sHist & " un-checked:"
Else
sHist = sHist & " NA un-Click:"
End If
sHist = sHist & sName & Chr(13) & Chr(13) &
Item.UserProperties("History")
Item.UserProperties("History") = sHist

authBU.Value = ""
Item.UserProperties(sName) = ""
authBUD.Value = "1/1/4501"
Item.UserProperties(sDate) = "1/1/4501"
Item.UserProperties(sCntrl) = chkBx.Value
authBU.ReadOnly = true
authBUD.ReadOnly = true
history.ReadOnly = true
Set history = Nothing
Set authBUD = Nothing
Set authBU = Nothing
Set myPage1 = Nothing
Set myPage2 = Nothing
Set myinspector = Nothing
End Function


Sub formResize()
Set myInspector = Item.GetInspector
myInspector.Width = wndrWidth
myInspector.Height = wndrHeight
Set myInspector = Nothing
End Sub
Function Item_Open()
'MsgBox "Open Event"
dontProcess = True
formResize()
restoreProp()
fills()
dontProcess = False
Item_Open = True
End Function
Function Item_Read()
'MsgBox "Read Event"
dontProcess = True
formResize()
restoreProp()
fills()
dontProcess = False
Item_Read = True
End Function
Function Item_Forward(myForwardItem)
'MsgBox "forward Event"
dontProcess = True
' dont resize the form here, we already have it the right size
saveProp()
fills()
dontProcess = False
Item_Forward = True
Item.MessageClass = msgClass
If Not Item.Saved Then
Item.Save
End If
Item.Close(olDiscard)
End Function
Sub fills()
fillProp "chkBU"
fillProp "chkIT"
fillProp "chkChanged"
fillProp "chkTested"
fillProp "chkReview"
fillProp "chkImplent"
fillProp "chkRequester"
fillProp "chkGranted"
fillProp "chkUpdated"
fillProp "chkRevoked"
fillProp "chkSent"
fillProp "chkClosed"
End Sub
Sub fillProp(sCntrl)
Set myinspector = Item.GetInspector
Set myPage1 = myInspector.ModifiedFormPages("Message")
Set chkBx = myPage1.Controls(sCntrl)
sStr = "NA" & Mid(sCntrl,4, (Len(sCntrl) - 3))
Set btnNA = myPage1.Controls(sStr)

chkBx.Value = Item.UserProperties(sCntrl)

If Item.UserProperties(sStr) = "True" Then
btnNA.Caption = "--"
chkBx.Enabled = False
'MsgBox "inside if"
End If

Set btnNA = Nothing
Set chkBx = Nothing
Set myPage1 = Nothing
Set myinspector = Nothing
End Sub
Sub saveProp()
Set myinspector = Item.GetInspector
Set myPage = myInspector.ModifiedFormPages("Message")
Set myPage1 = myInspector.ModifiedFormPages("History")
Item.UserProperties("priorityDDL") =
myPage.Controls("priorityDDL").Value
Item.UserProperties("impactDDL") = myPage.Controls("impactDDL").Value
Item.UserProperties("typeDDL") = myPage.Controls("typeDDL").Value
Item.UserProperties("History") = myPage1.Controls("History").Value
Item.UserProperties("chkBU") = myPage.Controls("chkBU").Value
Item.UserProperties("chkIT") = myPage.Controls("chkIT").Value
Item.UserProperties("chkChanged") =
myPage.Controls("chkChanged").Value
Item.UserProperties("chkTested") = myPage.Controls("chkTested").Value
Item.UserProperties("chkReview") = myPage.Controls("chkReview").Value
Item.UserProperties("chkImplent") =
myPage.Controls("chkImplent").Value
Item.UserProperties("chkGranted") =
myPage.Controls("chkGranted").Value
Item.UserProperties("chkUpdated") =
myPage.Controls("chkUpdated").Value
Item.UserProperties("chkRevoked") =
myPage.Controls("chkRevoked").Value
Item.UserProperties("chkSent") = myPage.Controls("chkSent").Value
Item.UserProperties("chkClosed") = myPage.Controls("chkClosed").Value
Item.UserProperties("AuthorizedBU") =
myPage.Controls("AuthorizedBU").Value
'MsgBox myPage1.Controls("AuthorizedBUDate").Value
Item.UserProperties("AuthorizedBUDate") =
safeDate(myPage.Controls("AuthorizedBUDate").Value)
Item.UserProperties("AuthorizedIT") =
myPage.Controls("AuthorizedIT").Value
Item.UserProperties("AuthorizedITDate") =
safeDate(myPage.Controls("AuthorizedITDate").Value)
Item.UserProperties("AuthorizedChanged") =
myPage.Controls("AuthorizedChanged").Value
Item.UserProperties("AuthorizedChangedDate") =
safeDate(myPage.Controls("AuthorizedChangedDate").Value)
Item.UserProperties("AuthorizedTested") =
myPage.Controls("AuthorizedTested").Value
Item.UserProperties("AuthorizedTestedDate") =
safeDate(myPage.Controls("AuthorizedTestedDate").Value)
Item.UserProperties("AuthorizedReview") =
myPage.Controls("AuthorizedReview").Value
Item.UserProperties("AuthorizedReviewDate") =
safeDate(myPage.Controls("AuthorizedReviewDate").Value)
Item.UserProperties("AuthorizedImplent") =
myPage.Controls("AuthorizedImplent").Value
Item.UserProperties("AuthorizedImplentDate") =
safeDate(myPage.Controls("AuthorizedImplentDate").Value)
Item.UserProperties("AuthorizedGranted") =
myPage.Controls("AuthorizedGranted").Value
Item.UserProperties("AuthorizedGrantedDate") =
safeDate(myPage.Controls("AuthorizedGrantedDate").Value)
Item.UserProperties("AuthorizedUpdated") =
myPage.Controls("AuthorizedUpdated").Value
Item.UserProperties("AuthorizedUpdatedDate") =
safeDate(myPage.Controls("AuthorizedUpdatedDate").Value)
Item.UserProperties("AuthorizedRevoked") =
myPage.Controls("AuthorizedRevoked").Value
Item.UserProperties("AuthorizedRevokedDate") =
safeDate(myPage.Controls("AuthorizedRevokedDate").Value)
Item.UserProperties("AuthorizedSent") =
myPage.Controls("AuthorizedSent").Value
Item.UserProperties("AuthorizedSentDate") =
safeDate(myPage.Controls("AuthorizedSentDate").Value)
Item.UserProperties("AuthorizedClosed") =
myPage.Controls("AuthorizedClosed").Value
Item.UserProperties("AuthorizedClosedDate") =
safeDate(myPage.Controls("AuthorizedClosedDate").Value)
Set myPage = Nothing
Set myPage1 = Nothing
Set myinspector = Nothing
End Sub
Sub restoreProp()
Set myinspector = Item.GetInspector
Set myPage = myInspector.ModifiedFormPages("Message")
Set myPage1 = myInspector.ModifiedFormPages("History")
myPage.Controls("priorityDDL").Value =
Item.UserProperties("priorityDDL")
myPage.Controls("impactDDL").Value = Item.UserProperties("impactDDL")
myPage.Controls("typeDDL").Value = Item.UserProperties("typeDDL")
myPage1.Controls("History").Value = Item.UserProperties("History")
myPage.Controls("chkBU").Value = Item.UserProperties("chkBU")
myPage.Controls("chkIT").Value = Item.UserProperties("chkIT")
myPage.Controls("chkChanged").Value =
Item.UserProperties("chkChanged")
myPage.Controls("chkTested").Value = Item.UserProperties("chkTested")
myPage.Controls("chkReview").Value = Item.UserProperties("chkReview")
myPage.Controls("chkRequester").Value =
Item.UserProperties("chkRequester")
myPage.Controls("chkImplent").Value =
Item.UserProperties("chkImplent")
myPage.Controls("chkGranted").Value =
Item.UserProperties("chkGranted")
myPage.Controls("chkUpdated").Value =
Item.UserProperties("chkUpdated")
myPage.Controls("chkRevoked").Value =
Item.UserProperties("chkRevoked")
myPage.Controls("chkSent").Value = Item.UserProperties("chkSent")
myPage.Controls("chkClosed").Value = Item.UserProperties("chkClosed")
myPage.Controls("AuthorizedBU").ReadOnly = False
myPage.Controls("AuthorizedBU").Value =
Item.UserProperties("AuthorizedBU")
myPage.Controls("AuthorizedBU").ReadOnly = True
myPage.Controls("AuthorizedBUDate").ReadOnly = False
myPage.Controls("AuthorizedBUDate").Value =
Item.UserProperties("AuthorizedBUDate")
myPage.Controls("AuthorizedBUDate").ReadOnly = True
myPage.Controls("AuthorizedIT").ReadOnly = False
myPage.Controls("AuthorizedIT").Value =
Item.UserProperties("AuthorizedIT")
myPage.Controls("AuthorizedIT").ReadOnly = True
myPage.Controls("AuthorizedITDate").ReadOnly = False
myPage.Controls("AuthorizedITDate").Value =
Item.UserProperties("AuthorizedITDate")
myPage.Controls("AuthorizedITDate").ReadOnly = True
myPage.Controls("AuthorizedChanged").ReadOnly = False
myPage.Controls("AuthorizedChanged").Value =
Item.UserProperties("AuthorizedChanged")
myPage.Controls("AuthorizedChanged").ReadOnly = True
myPage.Controls("AuthorizedChangedDate").ReadOnly = False
myPage.Controls("AuthorizedChangedDate").Value =
Item.UserProperties("AuthorizedChangedDate")
myPage.Controls("AuthorizedChangedDate").ReadOnly = True
myPage.Controls("AuthorizedTested").ReadOnly = False
myPage.Controls("AuthorizedTested").Value =
Item.UserProperties("AuthorizedTested")
myPage.Controls("AuthorizedTested").ReadOnly = True
myPage.Controls("AuthorizedTestedDate").ReadOnly = False
myPage.Controls("AuthorizedTestedDate").Value =
Item.UserProperties("AuthorizedTestedDate")
myPage.Controls("AuthorizedTestedDate").ReadOnly = True
myPage.Controls("AuthorizedReview").ReadOnly = False
myPage.Controls("AuthorizedReview").Value =
Item.UserProperties("AuthorizedReview")
myPage.Controls("AuthorizedReview").ReadOnly = True
myPage.Controls("AuthorizedReviewDate").ReadOnly = False
myPage.Controls("AuthorizedReviewDate").Value =
Item.UserProperties("AuthorizedReviewDate")
myPage.Controls("AuthorizedReviewDate").ReadOnly = True
myPage.Controls("AuthorizedRequester").ReadOnly = False
myPage.Controls("AuthorizedRequester").Value =
Item.UserProperties("AuthorizedRequester")
myPage.Controls("AuthorizedRequester").ReadOnly = True
myPage.Controls("AuthorizedRequesterDate").ReadOnly = False
myPage.Controls("AuthorizedRequesterDate").Value =
Item.UserProperties("AuthorizedRequesterDate")
myPage.Controls("AuthorizedRequesterDate").ReadOnly = True
myPage.Controls("AuthorizedImplent").ReadOnly = False
myPage.Controls("AuthorizedImplent").Value =
Item.UserProperties("AuthorizedImplent")
myPage.Controls("AuthorizedImplent").ReadOnly = True
myPage.Controls("AuthorizedImplentDate").ReadOnly = False
myPage.Controls("AuthorizedImplentDate").Value =
Item.UserProperties("AuthorizedImplentDate")
myPage.Controls("AuthorizedImplentDate").ReadOnly = True
myPage.Controls("AuthorizedGranted").ReadOnly = False
myPage.Controls("AuthorizedGranted").Value =
Item.UserProperties("AuthorizedGranted")
myPage.Controls("AuthorizedGranted").ReadOnly = True
myPage.Controls("AuthorizedGrantedDate").ReadOnly = False
myPage.Controls("AuthorizedGrantedDate").Value =
Item.UserProperties("AuthorizedGrantedDate")
myPage.Controls("AuthorizedGrantedDate").ReadOnly = True
myPage.Controls("AuthorizedUpdated").ReadOnly = False
myPage.Controls("AuthorizedUpdated").Value =
Item.UserProperties("AuthorizedUpdated")
myPage.Controls("AuthorizedUpdated").ReadOnly = True
myPage.Controls("AuthorizedUpdatedDate").ReadOnly = False
myPage.Controls("AuthorizedUpdatedDate").Value =
Item.UserProperties("AuthorizedUpdatedDate")
myPage.Controls("AuthorizedUpdatedDate").ReadOnly = True
myPage.Controls("AuthorizedRevoked").ReadOnly = False
myPage.Controls("AuthorizedRevoked").Value =
Item.UserProperties("AuthorizedRevoked")
myPage.Controls("AuthorizedRevoked").ReadOnly = True
myPage.Controls("AuthorizedRevokedDate").ReadOnly = False
myPage.Controls("AuthorizedRevokedDate").Value =
Item.UserProperties("AuthorizedRevokedDate")
myPage.Controls("AuthorizedRevokedDate").ReadOnly = True
myPage.Controls("AuthorizedSent").ReadOnly = False
myPage.Controls("AuthorizedSent").Value =
Item.UserProperties("AuthorizedSent")
myPage.Controls("AuthorizedSent").ReadOnly = True
myPage.Controls("AuthorizedSentDate").ReadOnly = False
myPage.Controls("AuthorizedSentDate").Value =
Item.UserProperties("AuthorizedSentDate")
myPage.Controls("AuthorizedSentDate").ReadOnly = True
myPage.Controls("AuthorizedClosed").ReadOnly = False
myPage.Controls("AuthorizedClosed").Value =
Item.UserProperties("AuthorizedClosed")
myPage.Controls("AuthorizedClosed").ReadOnly = True
myPage.Controls("AuthorizedClosedDate").ReadOnly = False
myPage.Controls("AuthorizedClosedDate").Value =
Item.UserProperties("AuthorizedClosedDate")
myPage.Controls("AuthorizedClosedDate").ReadOnly = True
Set myPage = Nothing
Set myPage1 = Nothing
Set myinspector = Nothing
End Sub
Function safeDate(sDate)
If sDate = "None" Then
safeDate = "1/1/4501"
Else
safeDate = FormatDateTime(sDate)
End If
End Function

Function chkDDLs()
Dim bVar
Dim sStr
sStr = ""
bVar = True
Set myinspector = Item.GetInspector
Set myPage1 = myInspector.ModifiedFormPages("Message")
Set tDDL = myPage1.Controls("typeDDL")
Set pDDL = myPage1.Controls("priorityDDL")
Set lDDL = myPage1.Controls("impactDDL") ' el-DD capital el
If Len(tDDL.Value) < 1 Then
sStr = "You Must Select an RFS Type" & Chr(13)
End If
If Len(pDDL.Value) < 1 Then
sStr = "You Must Select a Priority" & Chr(13)
End If
If Len(lDDL.Value) < 1 Then
sStr = "You Must Select an Authorization Level" & Chr(13)
End If
If Len(sStr) > 10 Then
' OK button only with Warning (48) icon
MsgBox sStr, 48, "Selections Missing"
bVar = False
End If
Set lDDL = Nothing
Set pDDL = Nothing
Set tDDL = Nothing
Set myPage1 = Nothing
Set myinspector = Nothing
chkDDLs = bVar
End Function
Function Item_Send(byVal myItem)
Dim sStr
Dim sUser
If Len(Item.Subject) < 10 Then
sStr = "Please use a descriptive Subject Line" & Chr(13) & _
"This Subject will be used to find the RFS later" & Chr(13) & _
"and should describe the RFS without too many details."
' OK button only with Warning (48) icon
MsgBox sStr, 48, "Missing or Ambiguous Subject"
Item_Send = False
Exit Function
End If
If not chkDDLs() Then
Item_Send = False
Exit Function
End If

' Everything is kosher so go ahead and do it
Set WshNetwork = CreateObject("WScript.Network")
sUser = WshNetwork.UserName
Set WshNetwork = Nothing
sStr = "Sent By " & sUser & " " & Now & Chr(13) & Chr(13) &
Item.UserProperties("History")
Item.UserProperties("History") = sStr
SaveToFolder()
'MsgBox myMain
' This is to be replaced with a copy statement to that folder
'Set Item.SaveSentMessageFolder = myMain
dontProcess = True
saveProp()
Item.MessageClass = msgClass
dontProcess = False
'MsgBox "done sending"
End Function
Sub SaveToFolder()
Set myMain = GetMAPIFolder(savePath)
If not myMain is nothing Then
Set objCopy = Item.Copy
objCopy.MessageClass = msgClass
If Not objCopy.Saved Then
objCopy.Save
End If
objCopy.Move myMain
Set objCopy = Nothing
End If
Set myMain = Nothing
End Sub

Function GetMAPIFolder(savePath)
Dim objNS
Dim objFolder
Dim objFolders
Dim arrName
Dim I
Dim blnFound

Set objNS = Application.GetNamespace("MAPI")

arrName = Split(savePath, "/")
Set objFolders = objNS.Folders
blnFound = False
For I = 0 To UBound(arrName)
For Each objFolder In objFolders
If objFolder.Name = arrName(I) Then
Set objFolders = objFolder.Folders
blnFound = True
Exit For
Else
blnFound = False
End If
Next
If blnFound = False Then
Exit For
End If
Next
If blnFound = True Then
Set GetMAPIFolder = objFolder
End If

Set objNS = Nothing
Set objFolder = Nothing
Set objFolders = Nothing
End Function
 
S

Sue Mosher [MVP-Outlook]

Add a new Yes/No property named IsCopy to your form and use its value to mark that the item is a copy:

Function Item_Send()
On Error Resume Next
If Item.UserProperties("IsCopy") = False Then
Set objCopy = Item.Copy
objCopy.UserProperties("IsCopy") = True
objCopy.Send
End If
End Function

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
R

rowan

Thanks, Sue!
I used the BillingInformation field, as I saw in another of your posts.
This worked, but I had to propogate it a little more than just the one
function. That did it nicely, though.
Thanks.
 

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