Public Sub sendnotification(ByVal docshortname As String, _
ByVal savepath As String, ByVal doclongname As String, _
ByVal documentpath As String, ByVal ContractID As String, _
ByVal Subject As String)
Try
Dim pdb As PWBdbase.PWBdbase = New PWBdbase.PWBdbase
Dim recipients As String = ""
Dim dt As DataTable = pdb.ContractStaff.Table(ContractID)
For Each row As DataRow In dt.Rows
If pdb.Nz(row(docshortname.ToString), False) Then
recipients &= pdb.Nz(row("Email"), "") & vbTab
End If
Next
If Right(recipients, 1) = vbTab Then recipients = Left(recipients, Len(recipients) - 1)
Dim recipientlist() = Split(recipients, vbTab)
If recipientlist.GetUpperBound(0) = -1 Then Return
Dim appOutlook As Object
Dim mi As Object
Dim Created As Boolean
Dim safeitem As Object
Dim olMailItem As Object
'Generate mail item
Dim myOlApp = CreateObject("Outlook.Application")
Dim myNameSpace = myOlApp.GetNamespace("MAPI")
myNameSpace.Logon()
safeitem = CreateObject("Redemption.SafeMailItem")
mi = myOlApp.CreateItem(olMailItem)
safeitem.Item = mi
'mi.Display
If Created Then appOutlook.Quit()
Dim recipientsadded As Boolean = False
For Each recipient As String In recipientlist
If Not recipient = "" Then
safeitem.Recipients.Add(recipient)
recipientsadded = True
End If
Next
If recipientsadded Then
'Get info and send mail
With safeitem.Item
.subject = Subject & " - PWB Automatic Notification"
.HTMLBody = "This message has been generated automatically." & "<br>" & _
"A new " & doclongname & " has been created for this Contract." & "<br>" & "<br>" & _
"Please click this link to goto the folder." & "<br>" & _
"<a href=" & Chr(34) & savepath & Chr(34) & ">" & savepath & "</a>" & "<br>" & "<br>" & _
"Or click this link to open the new document." & "<br>" & _
"<a href=" & Chr(34) & documentpath & Chr(34) & ">" & documentpath & "</a>"
End With
safeitem.send()
End If
mi = Nothing
If Created Then appOutlook.Quit()
appOutlook = Nothing
dt.Dispose()
dt = Nothing
recipientsadded = Nothing
recipientlist = Nothing
Catch ex As Exception
eh.log(ex)
End Try
End Sub