+ Reply to Thread
Results 1 to 2 of 2

Thread: Using dll to send email - Multithreading

  1. #1
    Barn Newbie sync_or_swim is an unknown quantity at this point sync_or_swim's Avatar
    Join Date
    May 2008
    Location
    South Wales
    Posts
    3
    Rep Power
    4

    Using dll to send email - Multithreading

    Hi Guys,

    I have been searching for a solution for a while but haven't made any headway, if anyone could give me any ideas I would be extremely grateful.

    The scenario is that I have been using CDOSYS to send automated emails from a number of Intranet pages within my organisation. Everything worked fine until a month or so ago, when we installed a new servicepack to our email system - Novell Groupwise.

    Since the upgrade, automatic emails intermittently fail, with the error:

    CDO.Message.1 error '80040213'

    The transport failed to connect to the server.

    /nmdb/checkform.asp, line 41

    Line 41 is the Line "cdoMessage.Send"

    After much experimentation, I found that, because I am sending the message directly to the smtp server and bypassing the mail sweeper, the smtp server assumes that the mail should come from an external domain - if it does not come from an external domain, the email is blocked. I suppose this makes sense because it means that I cant create an email saying that everyone has had a pay rise and pretend that it came from the MD!!!

    Unfortunately, some emails are still failing for no apparaent reason. To combat this I have created a VB6 dll to re-send the email if it fails, the code within the dll is:
    Code:
    Private Sub doSend(strTo, strFrom, strSubject, strMessage, strAttachment)
    On Error GoTo ErrorHandler
        
        Set imsg = CreateObject("cdo.message")
        Set iconf = CreateObject("cdo.configuration")
        Set Flds = iconf.Fields
        With Flds
            .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = 'IP Address of SMTP Server
            .Update
        End With
        Dim strReceiveremail, strFrom, strSubject, strHTML As String
          
        With imsg
            Set .Configuration = iconf
            .To = strTo
            .From = strFrom
            .Subject = strSubject
            .HTMLBody = strMessage
            .Fields.Update
            .AddAttachment (strAttachement)
            .Send
        End With
        Set imsg = Nothing
        Set iconf = Nothing
    ErrorHandler:
        If Err.Number <> 0 Then
            
            While Err.Number <> 0
                Call doSend
            Wend
            Unload Me
        End If
    End Sub
    
    I have registered the dll on the server and I can call the doSend function from my asp pages with the following code:
    Code:
    <%
    Dim strMessage
    strMessage = Request.Form("Full_Name") & vbVerticalTab & vbCrLf & "Submitted Feedback on " & Date & vbCr & "------------------------" & vbCrLf & "Question: " & Request.Form("Question")
    Dim objSendMail
    Set objSendMail = Server.CreateObject("AutoEMail.Class1")
    call objSendMail.doSend("sync_or_swim@test.co.uk", "someaddress@fakedomain.co.uk", "User Feedback Submitted", strMessage)
    Set objSendMail = Nothing
    Response.Write("Thank you. Your message has been sent to the Database Administrator")
    %>
    
    This is working, insomuch as all of my emails are being sent - the function is re-trying until they get through. My problem is that the page has to wait for the email to be sent until it can continue to load which may take 30 seconds.

    And now for my question, finally!!!

    Is there any way that I can call my dll from the asp page so that it runs in the background? Ie. So that it keeps trying to resend the message, but passes control back to the asp pages straight away so that I can do something else and the user doesn't have to wait for the email to send and there is no delay in the page loading.

    Does anybody know if this is possible or am I on a wild goose chase?

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Regarding the original problem...can't you point your script to relay through the Groupwise server to see if that will solve the problem?

    Regarding your question, I'm not sure if that's even possible.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


+ Reply to Thread

Similar Threads

  1. Simple way to email form
    By Rebelle in forum ASP Development
    Replies: 17
    Last Post: August 14th, 2008, 05:03 PM
  2. send Bulk email
    By peebman2000 in forum .NET Development
    Replies: 2
    Last Post: June 20th, 2008, 11:06 AM
  3. windows service send emails every 10 days
    By peebman2000 in forum .NET Development
    Replies: 8
    Last Post: May 20th, 2008, 05:00 PM
  4. VBS Send Mail
    By keep_it_simple in forum Windows Scripting
    Replies: 0
    Last Post: March 22nd, 2008, 12:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO