Link to home
Start Free TrialLog in
Avatar of IIS6_cursed
IIS6_cursed

asked on

different email results from the same code - one recipient only gets a "0" in the email

This one is a real challenge.  The code is listed below.  

The problem:  When someone submits a request using this form, two emails are generated.  One to my work email account, and the other to a general mailbox for the department that fills the request.  The email I receive looks fine and works without problem, but the email the department gets simply has a "0" in it.  That's all -  no information, no data, just a 0.  I'm using the same process to generate both emails, so this doesn't make any sense.

Any ideas?  Is this a coding issue or is something wrong with the other mailbox?  This form worked fine for them when we were on an IIS5 server - but since we migrated to IIS6, it doesn't want to work.  Please advise.  Thanks!

<%
' Setup E-mail and send to Network Management...
Set myMail = Server.CreateObject("CDO.Message")

myMail.From = objUpload.Form.Item(6)
myMail.To = "m6_nmanalysis@healthlink.com"
myMail.To = "bptouch@healthlink.com"

myMail.Subject = "GR-" & currentNetManGRNum & " / " & objUpload.Form.Item(2)

If objUpload.Files.Count > 0 Then
      For lngLoop = 0 to objUpload.Files.Count - 1
            myMail.AddAttachment Server.MapPath("../Data/" & objUpload.Files.Item(lngLoop).FileName)
      Next
End If

myMail.TextBody = 1
myMail.HtmlBody = 0

myBodyText = "-----------------------"
myBodyText = myBodyText & vbCrLf
myBodyText = myBodyText & "REQUESTOR'S INFORMATION"
myBodyText = myBodyText & vbCrLf
myBodyText = myBodyText & "-----------------------"
myBodyText = myBodyText & vbCrLf & vbCrLf
myBodyText = myBodyText & "Requested By:"
myBodyText = myBodyText & vbCrLf
myBodyText = myBodyText & "   Name: " & objUpload.Form.Item(4) & " " &  objUpload.Form.Item(5)
myBodyText = myBodyText & vbCrLf
myBodyText = myBodyText & "   E-Mail: " & objUpload.Form.Item(6)
myBodyText = myBodyText & vbCrLf
myBodyText = myBodyText & "   Department: " & objUpload.Form.Item(8)
myBodyText = myBodyText & vbCrLf
myBodyText = myBodyText & "   Phone Number: " & objUpload.Form.Item(7)
myBodyText = myBodyText & vbCrLf & vbCrLf
myBodyText = myBodyText & "---------------------"
myBodyText = myBodyText & vbCrLf
myBodyText = myBodyText & "DATE REQUESTED/NEEDED"
myBodyText = myBodyText & vbCrLf
myBodyText = myBodyText & "---------------------"
myBodyText = myBodyText & vbCrLf & vbCrLf
myBodyText = myBodyText & "Date Requested: " & FormatDateTime(Date(),1)
myBodyText = myBodyText & vbCrLf
myBodyText = myBodyText & "Date Needed: " & objUpload.Form.Item(1)
myBodyText = myBodyText & vbCrLf & vbCrLf
myBodyText = myBodyText & "----------------------------"
myBodyText = myBodyText & vbCrLf
myBodyText = myBodyText & "ANALYST GENERAL REQUEST INFO"
myBodyText = myBodyText & vbCrLf
myBodyText = myBodyText & "----------------------------"
myBodyText = myBodyText & vbCrLf & vbCrLf
myBodyText = myBodyText & "Analyst General Request Form Number: GR-" & currentNetManGRNum
myBodyText = myBodyText & vbCrLf & vbCrLf
myBodyText = myBodyText & "Short Description: " & objUpload.Form.Item(2)
myBodyText = myBodyText & vbCrLf & vbCrLf
myBodyText = myBodyText & "Description: " & objUpload.Form.Item(3)
myBodyText = myBodyText & vbCrLf & vbCrLf

If objUpload.Files.Count > 0 Then
      myBodyText = myBodyText & "Attached File(s) or Document(s): The requester attached " & objUpload.Files.Count & " file(s) to this form."
Else
      myBodyText = myBodyText & "Attached File(s) or Document(s): The requester did not attach any files to this form."
End If

myMail.TextBody = myBodyText

myMail.Send

Set myMail = Nothing
%>

Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

It sounds like it is sending the message as HTML rather than Text, I guess it is 0 because of the line:

    myMail.HtmlBody = 0

Although I'm not sure why you have the two lines:

    myMail.TextBody = 1
    myMail.HtmlBody = 0

Try removing those two lines and see what happens.
Avatar of IIS6_cursed
IIS6_cursed

ASKER

OK, I tried commenting out the HTMLBody line, and this time they didn't even get an email.  Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
do myMail.To = "John <john@some_domain.com>; Gary <gary@some_domain.com>"
That did it, Carl.  Thanks a world for your help!