|
-
Feb 6th, 2006, 09:37 AM
#1
Thread Starter
Fanatic Member
Catastrophic fail
Guys,
I am intermittently getting a Catastrophic fail error when trying to send e-mail messages through Outlook. I am not seeing this all the time, I cannot tie it down to specific users, mail profiles, machines, servers etc etc. I have posted the exception stack trace below, and also the code/module it seems to be hitting the error in. Has anybody had any experience of this, or can anybody see any issues with my code ?
Like I said, this is intermittent, 75% of the time it is working fine.
Thanks in advance,
Bob
EDIT - I should mention that I am using Outlook Redemption to bypass security messages, but this has never been an issue, its always worked well.
Exception: COMException
Stack Trace:
at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
at SQLWorkbook.EMail.sendnotification(String docshortname, String savepath, String doclongname, String documentpath)
at SQLWorkbook.uc_MaterialsReceived.btn_save_Click(Object sender, EventArgs e)
VB Code:
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
"I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|