Showing posts with label Email Sending with Google Authentication and With Google APPS Authentication. Show all posts
Showing posts with label Email Sending with Google Authentication and With Google APPS Authentication. Show all posts

Wednesday, 12 September 2012

Email Sending With Gmail, Google Apps in ASP 2.0


Email Sending With Gmail, Google Apps in ASP 2.0
------------------------------------------------------------------------------------------------------------
<%
'On Error Resume Next
Dim Subject, Body, SenderEmail, RecipientEmail, SMTPServer, SMTPusername, SMTPpassword
SenderEmail = "info@domain name.com"
SMTPserver = "smtp.gmail.com"
SMTPusername = "info@gmail.com"
'SMTPusername = "info@googleapps username.com" for google APPS
SMTPpassword = "PASSWORD"
'SMTPpassword = "PASSWORD" google APPS password
Subject = "Hello"
Body = "This is a test. Please ignore."
RecipientEmail= "email@domain name.com"

sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "smtpauthenticate") = 1
.Item(sch & "smtpusessl") = True
.Item(sch & "smtpserver") = SMTPserver
.Item(sch & "sendusername") = SMTPusername
.Item(sch & "sendpassword") = SMTPpassword
.Item(sch & "smtpserverport") = 465
.Item(sch & "sendusing") = 2
.Item(sch & "connectiontimeout") = 100
.update
End With

'Const cdoSendUsingPickup = "c:\inetpub\mailroot\pickup"
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
cdoMessage.From = SenderEmail
cdoMessage.To = RecipientEmail
cdoMessage.Subject = Subject
cdoMessage.TextBody = Body
cdoMessage.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
If Err.Number <> 0 Then
  Response.Write (Err.Description& "<br><br>")
end if
%>