How Do I Get A System Email Sent To Me?
I'm about to add the capability to my app for a user to submit data to a database. The data will be sort of like "sign my guestbook" level but not quite a guestbook. The data will be displayed for all to see. So I want to be sent an email that let's me know that someone submitted data so that I can see what was written almost as soon as it's written so that I can delete it, if need be. I'm using MSSQL 2008 on WinHost, ASP.NET 4.0.
Can someone please give me a rough idea on how to do this and I'll implement it?
Re: How Do I Get A System Email Sent To Me?
There are several methods for this...
#1: use the hosting servers SMTP to send the mail (Mail Pickup directory method)...
Code:
Dim ObjSendMail
Dim ObjConfig
Dim Flds
ObjSendMail = Server.CreateObject("CDO.Message")
ObjConfig = CreateObject("CDO.Configuration")
Flds = ObjConfig.Fields
Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
'----- DBL check path for mail pickup...
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup"
Flds.Update
ObjSendMail.Configuration = ObjConfig
ObjSendMail.To = "email@example.com"
ObjSendMail.Subject = "subject"
ObjSendMail.From = "admin@yourmail.net"
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"
ObjSendMail.Send
ObjSendMail = Nothing
#2: connection directly to a remote SMTP mail server..
Code:
Dim ObjSendMail
Dim ObjConfig
Dim Flds
ObjSendMail = Server.CreateObject("CDO.Message")
ObjConfig = CreateObject("CDO.Configuration")
Flds = ObjConfig.Fields
Flds.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 '(SMTP).
Flds.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.server.com"
Flds.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
Flds.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
Flds.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
' autentication details
Flds.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
Flds.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="yourusername"
Flds.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"
Flds.Update
ObjSendMail.Configuration = ObjConfig
ObjSendMail.To = "email@example.com"
ObjSendMail.Subject = "subject"
ObjSendMail.From = "admin@yourmail.net"
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"
ObjSendMail.Send
ObjSendMail = Nothing
Re: How Do I Get A System Email Sent To Me?
these are really good examples... thanks...