'+++++ Send Emails
Dim mailInDom As XmlDocument = New XmlDocument()
Dim activeAssignment As XmlElement
Dim activity As XmlElement
Dim elem As XmlElement
Dim flagNm As String = "use_identities_from_xml_only"
Dim act_asnees_dict As New Hashtable 'key is activity&assignee (indicates that assignee is emailed about the activity)
Dim k As String
For i = 0 To activities4email.Count - 1
activity = CType(activities4email.Item(i), XmlElement)
mailInDom.LoadXml(activity.OuterXml)
elem = CType(mailInDom.SelectSingleNode("Item/Relationships"), XmlElement)
If Not elem Is Nothing Then elem.ParentNode.RemoveChild(elem)
mailInDom.DocumentElement.SetAttribute(flagNm, "1")
k = String.Format(CultureInfo.InvariantCulture, "{0};{1}", activity.GetAttribute("id"), CCO.XML.GetItemProperty(activity, "managed_by_id"))
act_asnees_dict.Add(k, "")
CCO.ApplyItem.ExecuteMethodByName(mailInDom, outDom, "sendEmailToA2Assignee", True)
If (CCO.XML.HasFault(outDom, False)) Then
Exit Sub
End If
Next
For i = 0 To asmnts4email.Count - 1
activeAssignment = CType(asmnts4email.Item(i), XmlElement)
activity = CType(activeAssignment.ParentNode.ParentNode, XmlElement)
elem = CType(activeAssignment.SelectSingleNode("related_id/Item"), XmlElement)
If elem Is Nothing Then
k = activeAssignment.SelectSingleNode("related_id").InnerText
Else
k = elem.GetAttribute("id")
End If
k = String.Format("{0};{1}", activity.GetAttribute("id"), k)
If Not act_asnees_dict.Contains(k) Then
mailInDom.LoadXml(activity.OuterXml)
For Each elem In mailInDom.SelectNodes(String.Format("Item/Relationships/Item[@id!='{0}']", activeAssignment.GetAttribute("id")))
elem.ParentNode.RemoveChild(elem)
Next elem
mailInDom.DocumentElement.SetAttribute(flagNm, "1")
CCO.ApplyItem.ExecuteMethodByName(mailInDom, outDom, "sendEmailToA2Assignee", True)
If (CCO.XML.HasFault(outDom, False)) Then
Exit Sub
End If
act_asnees_dict.Add(k, "")
End If
Next
'----- Send Emails
This should prevent the emails from being sent, but I have not tested this workaround to confirm. Be sure to thoroughly test to ensure that the behavior when assigning activities does not change.