View Full Version : Website updates, I get an email
8mycsh
09-26-2002, 07:27 AM
Hi,
Heres whats up. I have an asp form and it updates another area of my site. What I want to do is when the add button is clicked I want it to send me an email saying someone has posted a message. What would be the best way.
I am very new to asp and it took me a while to build this form but I am learning asp slowly. I was curious if I can attach a string of code just to the add button so when clicked it emails me. Is this possible....I have looked at asp101.com's site and it had some email demos but I am not sure if thats what I need.
Can someone help me.
Thanks
Mhtml
09-26-2002, 12:13 PM
I am in my 2nd month of learning asp now and I have just made my email script, for my contact page http://24.226.62.28/projectodyssey/contact.asp
I guess, the easiest way to do this is to modify my script and insert into yours. I have commented each part so you know what is happening at each part of the script.
Just edit the GOES HERE parts.
just put this script after or before your update script.
<%'The below line declares global variables
Dim objCDONTS, strFromName, strFromEmail, strToEmail, strSubject, strBody, misccompo, ReplyMsg
'Email info name address to send to email text etc
strFromName = "NAME_GOES_HERE" 'The name you want in the from part of the email
strSubject = "SUBJECT_GOES_HERE " 'Site updated or whatever you want for the subject
strToEmail = "YOUR_EMAIL_GOES_HERE" 'Your email address goes here
strBody = "YOUR_MESSAGE_GOES_HERE" 'This is what the text of the email will be
'This next part actually creates and sends the email,
Set objCDONTS = Server.CreateObject("CDONTS.NewMail") 'Creates the variable to store the finction
objCDONTS.From = strFromName & " <" & strFromEmail & ">" 'Calls the from info
objCDONTS.To = strToEmail 'Calls the email to info
objCDONTS.Subject = strSubject 'Calls the subject info
objCDONTS.Body = strbody 'Calls the message text
objCDONTS.Body = strbody & vbcrlf & "Sent -" & Date() & " at " & time() 'Adds send time info at the bottom
objCDONTS.Send 'Sends the email
'Set the variable objCDONTS to nothing because once the email is sent it is dead
Set objCDONTS = Nothing
%>
whammy
09-26-2002, 10:59 PM
Here's a snippet I use:
Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.To = ""
objMail.From = ""
objMail.cc = ""
objMail.bcc = ""
'objMail.mailFormat = 0 'This is for HTML
'objMail.bodyFormat = 0 'This is for HTML
MessageBody = "" & CHR(13)
MessageBody = MessageBody & "" & CHR(13)
objMail.Subject = ""
objMail.Body = MessageBody
objMail.Send
Set objMail = Nothing
8mycsh
09-27-2002, 02:44 AM
Ok I have used the coding that Mhtml supplied changing the things to make it active and apply to me. But now I have this error:
Microsoft VBScript runtime error '800a0046'
Permission denied
/add_or_edit.asp, line 144
This has to do with the server correct. Does it also apply to the coding? I have went to line 144 and it is the objConts.send function. Like I said I am very new to this.
Also can anyone recommend a good ASP book?
Thanks
whammy
09-27-2002, 03:10 AM
Who's your web host?
8mycsh
09-27-2002, 04:01 AM
Its a small compnay here in Alberta, Canada. They are running win 2000 server and IIS 5.0 with MS exchange 2000.
They just started hosting so they have gotten everything up and running completely. I did some investigating and found some info on the error:
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q197619&LN=EN-US
It says for IIS 4.0 could it also be for IIS 5.0?
whammy
09-27-2002, 04:27 AM
Yeah... I'd talk to your host, they might have a specific folder or something that has permissions to send mail...
I asked that, because that's one problem with the free service on Brinkster.... you can do lots of stuff but you can't send emails!
8mycsh
09-27-2002, 05:07 AM
I will talk to my service provider .
Thanks for all your help.
8mycsh
09-27-2002, 11:38 PM
Hi again,
I was curious if this coding can be changed to work with w3Jmail4. The coding I am talking about is from Mhtml. I talked to my service provider and they are working out the bugs they keep gettin errors. So can I change this coding in to something that works with w3JMail4?
Thanks for yor help.
whammy
09-28-2002, 12:37 AM
I'm not sure... that must be a third-party component. Do you have the URL to their website?
And are you sure that this components' .dll is registered on the host?
8mycsh
09-28-2002, 06:56 PM
The w3Jmail4 is a version of Jmail. It works like every other Jmail program. I have done some research and I all I have to do is change the coding to act with Jmail instead of cdonts.
Mhtml
09-29-2002, 09:20 AM
so instead of say, cdonts.send you use jmail.send?
I think I have it installed on my computer but never figured out how to use it lol.:)
edit:
what was I thinking, not quite with it. You would change the server.createobject(cdonts..... part to jmail ???
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.