VBScript Email Issue

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Knotical

Thread Starter
Joined
Oct 27, 2003
Messages
8
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()>
</form>

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"
cnn.Open

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")
f1.Delete()
set f1 = fso.CreateTextFile("c:\temp\message.htm",ForWriting,True)
f1.Write(rst("tmpText"))
f1.close
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.Update
objMessage.Send 1,1,0
objSession.Logoff
rst.close

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

--
Anyone understand this? Any suggestions?
 
Joined
Sep 21, 2001
Messages
507
How many machines have you tested the script on? This could be an isolated issue with a specific machine.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Members online

No members online now.
Top