Results 1 to 6 of 6

Thread: Catastrophic fail

  1. #1

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    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:
    1. Public Sub sendnotification(ByVal docshortname As String, _
    2.      ByVal savepath As String, ByVal doclongname As String, _
    3.      ByVal documentpath As String, ByVal ContractID As String, _
    4.      ByVal Subject As String)
    5.  
    6.         Try
    7.             Dim pdb As PWBdbase.PWBdbase = New PWBdbase.PWBdbase
    8.  
    9.             Dim recipients As String = ""
    10.             Dim dt As DataTable = pdb.ContractStaff.Table(ContractID)
    11.             For Each row As DataRow In dt.Rows
    12.                 If pdb.Nz(row(docshortname.ToString), False) Then
    13.                     recipients &= pdb.Nz(row("Email"), "") & vbTab
    14.                 End If
    15.             Next
    16.             If Right(recipients, 1) = vbTab Then recipients = Left(recipients, Len(recipients) - 1)
    17.             Dim recipientlist() = Split(recipients, vbTab)
    18.             If recipientlist.GetUpperBound(0) = -1 Then Return
    19.  
    20.             Dim appOutlook As Object
    21.             Dim mi As Object
    22.             Dim Created As Boolean
    23.             Dim safeitem As Object
    24.             Dim olMailItem As Object
    25.  
    26.             'Generate mail item
    27.             Dim myOlApp = CreateObject("Outlook.Application")
    28.             Dim myNameSpace = myOlApp.GetNamespace("MAPI")
    29.             myNameSpace.Logon()
    30.             safeitem = CreateObject("Redemption.SafeMailItem")
    31.             mi = myOlApp.CreateItem(olMailItem)
    32.             safeitem.Item = mi
    33.             'mi.Display
    34.             If Created Then appOutlook.Quit()
    35.  
    36.             Dim recipientsadded As Boolean = False
    37.             For Each recipient As String In recipientlist
    38.                 If Not recipient = "" Then
    39.                     safeitem.Recipients.Add(recipient)
    40.                     recipientsadded = True
    41.                 End If
    42.             Next
    43.  
    44.             If recipientsadded Then
    45.                 'Get info and send mail
    46.                 With safeitem.Item
    47.                     .subject = Subject & " - PWB Automatic Notification"
    48.                     .HTMLBody = "This message has been generated automatically." & "<br>" & _
    49.                     "A new " & doclongname & " has been created for this Contract." & "<br>" & "<br>" & _
    50.                     "Please click this link to goto the folder." & "<br>" & _
    51.                     "<a href=" & Chr(34) & savepath & Chr(34) & ">" & savepath & "</a>" & "<br>" & "<br>" & _
    52.                     "Or click this link to open the new document." & "<br>" & _
    53.                     "<a href=" & Chr(34) & documentpath & Chr(34) & ">" & documentpath & "</a>"
    54.                 End With
    55.                 safeitem.send()
    56.             End If
    57.  
    58.             mi = Nothing
    59.             If Created Then appOutlook.Quit()
    60.             appOutlook = Nothing
    61.             dt.Dispose()
    62.             dt = Nothing
    63.             recipientsadded = Nothing
    64.             recipientlist = Nothing
    65.  
    66.         Catch ex As Exception
    67.            eh.log(ex)
    68.         End Try
    69.  
    70.  
    71.     End Sub
    "I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Catastrophic fail

    "Microsoft.VisualBasic.CompilerServices.LateBinding"
    Do you have option explicit turned on?

  3. #3

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    Re: Catastrophic fail

    I do now, and it still builds/runs and still may or may not show the error ?

    Thanks
    Bob
    "I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Catastrophic fail

    can you find any common links in the actual parameters being used to send the email (ie recipent, message, etc) when the routine fails?

  5. #5
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Catastrophic fail

    Sorry, I meant option strict.

  6. #6

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    Re: Catastrophic fail

    OK, Option Strict disallows late binding which I need to use in this case.

    Matt - the only common thing I can see when failing is the fact that the users Outlook profile has some delegated permissions, send on behalf permissions etc. The recipients list always resolves, ie it finds all items in the address list, so its not like I have bad e-mail addresses.
    "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
  •  



Click Here to Expand Forum to Full Width