CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012
    Posts
    1

    Unable to send email via ASP: iam using Gmail - SMTP

    I have one application which I create in ASP. But from few days email function not working. Can anyone help me.

    This is the code

    Code:
    <%
    txtBodyT="<table style='background-color:#CCCCCC; border-bottom-color:#CCCCCC; border-bottom-style:solid; border-bottom-width:0px; border-top-color:#CCCCCC; border-top-style:solid; border-top-width:0px; border-left-color:#CCCCCC; border-left-style:solid; border-left-width:40px; border-right-color:#CCCCCC; border-right-style:solid; border-right-width:40px;' width='70%'>"
    txtBodyT=txtBodyT&"<tr>"
    txtBodyT=txtBodyT&"<td>"
    txtBodyT=txtBodyT&html
    txtBodyT=txtBodyT&"</td>"
    txtBodyT=txtBodyT&"</tr>"
    txtBodyT=txtBodyT&"</table>"
    subjectM="DIAL HR Apply for "& txtTotalApply &" "&txtLeaveType'"Test Send mail from localhost"
    Set objMessage = CreateObject("CDO.Message") 
    objMessage.Subject = subjectM
    objMessage.From = txtFromEmail
    objMessage.To = txtNPEMAIL
    objMessage.CC = "dialhr2011@gmail.com"
    'objMessage.BCC = "puneet.rawat@gdfsuez.com" 
    objMessage.HTMLBody  = txtBodyT
    'objMessage.TextBody = html'"This is some sample message text."
    
    '==This section provides the configuration information for the remote SMTP server.
    
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    
    'Name or IP of Remote SMTP Server
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" 'dbserver1.tractebel.net.in smtp.gmail.com
    
    'Type of authentication, NONE, Basic (Base64 encoded), NTLM
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    
    'Your UserID on the SMTP server
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myid@gmail.com"
    
    'Your password on the SMTP server
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"'---------password
    
    'Server port (typically 25)
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
    
    'Use SSL for the connection (False or True)
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1 'false'1
    
    'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    
    If intSendUsing = 1 Then
    	'objMessage.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup" 
    End If
    
    objMessage.Configuration.Fields.Update
    
    '==End remote SMTP server configuration section==
    on error resume next
    objMessage.Send
    if err<>0 then
    	'Response.Write(err.File&"<br />")
    	Response.Write(err.Number&"<br />")
    	Response.Write(err.Description&"<br />")
    	Response.Write(err.Source&"<br />")
    else
    	Response.Write("<br />Message Send... :)<br/>" & txtBodyT)
    end if
    	Response.Write("<br />Message Send... :)<br/>" & txtBodyT)
    %>

  2. #2
    Join Date
    Sep 2006
    Posts
    635

    Re: Unable to send email via ASP: iam using Gmail - SMTP

    Quote Originally Posted by puneet_pr View Post
    But from few days email function not working.
    hi
    this doesn't help much
    what error message is showed in page???
    event viewer (OS Windows) says something about??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured