1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

VBScript Email Issue

Discussion in 'Software Development' started by Knotical, Jan 23, 2007.

Thread Status:
Not open for further replies.
  1. Knotical

    Knotical Thread Starter

    Oct 27, 2003
    I'm fixing up an ASP web app that contains one bit of VBScript that appears to not be working properly and I don't understand where. I don't know anything about VBScript. The system is on Windows 2003 Server, IIS, MS SQL and ASP (not ASP.NET).

    The code creates an email message in the user's outbox (on Exchange) with the results from the database. I guess the user is left to open the message to fill in the address, subject and additional text.

    It actually seems to work - the message is properly created in the outbox. However, an additional instance of "Microsoft Office Outlook" opens and both it and the browser hang. Outlook continues along fine and the message can be opened and sent as expected.

    The code is called like this:
    <form name=SendMail>
    <input type=button value="Create Email" OnClick=DoMail()>

    And this is the VBScript included in the same .asp file:

    <script language=VBScript>
    sub DoMail()
    on error resume next
    CurUser = "<%=Request.ServerVariables("AUTH_USER")%>"
    anID = "<%=Request.QueryString("ID")%>"

    strProfileInfo = "APPSERVER" & chr(10) & CurUser

    Set objSession = CreateObject("MAPI.Session")
    objSession.Logon , , False, True, 0, True, strProfileInfo

    Set objMessage = objSession.Outbox.Messages.Add

    set cnn = CreateObject("ADODB.Connection")
    set rst = CreateObject("ADODB.RecordSet")
    cnn.ConnectionString = "Provider=sqloledb;Server=dbserver;UID=IUSR;PWD=aPassword;Initial Catalog=Internal Database"

    SQLString = "SELECT Text AS tmpText, Title as tmpTitle FROM Messages WHERE ID='" & anID & "'"
    rst.Open SQLString, cnn

    set fso = CreateObject("Scripting.FileSystemObject")
    set f1 = fso.GetFile("c:\temp\message.htm")
    set f1 = fso.CreateTextFile("c:\temp\message.htm",ForWriting,True)
    set fso = nothing

    set objAttach = objMessage.Attachments
    set objMessage.Subject = rst("tmpTitle")
    set tmpAttach = objAttach.Add("c:\temp\message.htm",,,"c:\temp\message.htm")

    objMessage.Send 1,1,0

    set rst = nothing
    set cnn = nothing
    set objMessage = nothing
    set objSession = nothing
    end sub

    Anyone understand this? Any suggestions?
  2. asbo


    Sep 21, 2001
    How many machines have you tested the script on? This could be an isolated issue with a specific machine.
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/537601

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice