473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Sending an email using ASP - Problem

Hello everyone:

I've been working on making some changes to the website for the company that I am currently an intern for. There is a function that they have in one of their files that uses CDOSYS to allow visitors to our site to email us with a support request. I've been testing this functionality out, but the emails aren't actually being sent to our email addresses. I've looked all over the internet for how to send an email using ASP, and the code that is part of our file (which appears below) looks like it is doing everything I need it to. This is the function used to send an email:

Expand|Select|Wrap|Line Numbers
  1. function SendEmail(strEmailText, strEmailSubject, strEmailTo, strEmailFrom)
  2. '*** Returns True if email was sent.
  3. '*** Returns False if an error occurred.
  4.  
  5.     on error resume next
  6.     Set objMail = Server.CreateObject("CDO.Message")
  7.  
  8.     objMail.From = strEmailFrom
  9.     objMail.To = strEmailTo
  10.     objMail.Subject = strEmailSubject
  11.     objMail.TextBody = strEmailText
  12.  
  13.     objMail.Send
  14.  
  15.     Set objMail = Nothing
  16.  
  17.     if err.number then
  18.         '*** error occurred while sending mail
  19.         SendEmail = False
  20.         Response.Write (err.Description)
  21.     else
  22.         SendEmail = True
  23.     end if        
  24.     On Error GoTo 0
  25.  
  26. end function
  27.  
So, basically, I'm setting objMail equal to a CDO message, and I'm setting the From, To, Subject, and TextBody of the message equal to the appropriate parameters. Now while I've been doing tests, I've checked to see whether True or False has been returned by the function, and each time True has been returned. For some reason though, the emails aren't appearing in our Inbox (and they aren't appearing in our Spam filters either). I can't really see why this isn't working properly, so I thought I'd ask everyone here if there's anything I'm missing in this function that is causing the emails to not be sent.

I will greatly appreciate any help/input I receieve.

Thank you in advance!
Apr 14 '08 #1
5 1622
DrBunchman
979 Expert 512MB
Hi WaluigiCubed,

You haven't configured a port or smtp server in your code so you're using the defaults (25 and localhost).

Have you got smtp configured in the IIS of the machine that is running this website?

If so have you tested it?

Dr B
Apr 14 '08 #2
Hi WaluigiCubed,

You haven't configured a port or smtp server in your code so you're using the defaults (25 and localhost).

Have you got smtp configured in the IIS of the machine that is running this website?

If so have you tested it?

Dr B
Well, I asked my boss about this, and he said that Port 25 is OK, but he said that SMTP wasn't configured in the IIS of the machine running the website. He wants it to go through our Microsoft Exchange Server though. So, I did some searching on how to route the emails to an Exchange Server, but I have had no luck. Does anyone have any ideas of how to route the email to the Exchange Server before sending it out (if it is even possible)?

Thanks in advance!
Apr 16 '08 #3
DrBunchman
979 Expert 512MB
I don't know anything about Microsoft Exchange but to send mail via a remote mail server you can do the following. Include the following lines in your script before the objMail.send. These lines configure the port number and mail server to use so substitute the IP of your mail server where indicated and see if it works.
Expand|Select|Wrap|Line Numbers
  1.  
  2. objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
  3. 'Name or IP of Remote SMTP Server
  4. objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "name or IP of mail server"
  5. 'Server port (typically 25)
  6. objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
  7. objMail.Configuration.Fields.Update
  8.  
Give it a go and let me know how you get on.

Dr B
Apr 17 '08 #4
That works perfectly DrBrunchman. Thank you so very much! ^_^
Apr 18 '08 #5
DrBunchman
979 Expert 512MB
No problem Waluigi, glad to be of help.
Apr 18 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Paul Lamonby | last post by:
Hi, I am sending a file from the server as an email attachment. The file is being attached no problem and sending the email, but I get an error when I try to open it saying it is corrupt....
17
by: Bonj | last post by:
Right guys. (I would like a solution to this in VB6 as this is what our needy app is written in, but any solutions that involve .NET would be much appreciated likewise as I could instantiate...
2
by: Mark | last post by:
I have a service that I've built that runs on our web server. The web service has a reference to the System.Web namespace so it can use the classes titled: MailMessage SmtpMail My web...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
5
by: Jai | last post by:
Hi, I am in a problem of sending mass emails(newsletter) to my website members. Actually my problem is this: I want to send newsletter to my website members. But I had given a facility for...
2
by: =?Utf-8?B?QWRl?= | last post by:
HI All, I am encountering the following error when I try to send an email through a SMTP server. I believe the problem lies with the authentication part when the network crednetials are used,...
9
by: JoeP | last post by:
Hi All, How can I find the reason for such an error: Failure sending mail. Some Code... oMailMessage.IsBodyHtml = False oMailMessage.Body = cEmailBody Dim oSMTP As New SmtpClient...
6
by: Jack | last post by:
Hi, I am still new to .NET so, i'm sorry if my question is a bit too simple :-) I would like to know what is the "best-practice-way" of sending email from asp.net (VbScript). I want to make a...
7
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to...
10
by: Markgoldin | last post by:
I am sending an XML data from not dontnet process to a .Net via socket listener. Here is a data sample: <VFPData> <serverdata> <coderun>updateFloor</coderun> <area>MD2</area>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.