Hi , My simple code to send mail is this <% sch = "http://schemas.microsoft.com/cdo/configuration/" Set cdoConfig = CreateObject("CDO.Configuration") With cdoConfig.Fields .Item(sch & "sendusing") = 2 ' cdoSendUsingPort .Item(sch & "smtpserver") = "<enter_mail.server_here>" .update End With Set cdoMessage = CreateObject("CDO.Message") With cdoMessage Set .Configuration = cdoConfig .From = "rag84dec@gmail.com" .To = "rag84dec@gmail.com" .Subject = "Sample CDO Message" .TextBody = "This is a test for CDO.message" .Send End With Set cdoMessage = Nothing Set cdoConfig = Nothing %> Code (markup): But it is giving me an error Error Type: CDO.Message.1 (0x80040213) The transport failed to connect to the server. /testmail.asp, line 21 Code (markup): Can any one help me please
hi rag, You need a way to give them your password, and connect to gmail smtpserver. Try something like Dim SmtpServer As New SmtpClient() SmtpServer.Credentials = New Net.NetworkCredential("rag84dec@gmail.com", "###RAG84's PASSWORD###") SmtpServer.Port = 587 SmtpServer.Host = "smtp.gmail.com" SmtpServer.EnableSsl = True Code (markup): there might be a way to do that with your ".item" - i've never done it that way though then maybe something like this Dim mail As New MailMessage() mail = New MailMEssage() mail.From = New MailAddress("rag84dec@gmail.com","rag",System.Text.Encoding.UTF8) mail.To = "rag84dec@gmail.com" mail.Subject = "hihihi subject" mail.TextBody = "This is a test message" Code (markup): sorry if its a bit sloppy i dont do VB code Ideally there would be some try/catch magic in there, and maybe some delivery/replyTo stuff as well... Hope that helps! Peace.
hmmmm CDO...... Pardon my previous c0de (though i think it would work) This is more inline with the code you posted: .Item(sch & "sendusing") = 2 .Item(sch & "smtpserver") = "smtp.gmail.com" .Item(sch & "smtpserverport") = ???//Something need to go here and im not sure what .Item(sch & "smtpauthenticate") = 1 .Item(sch & "sendusername") = "mymail@gmail.com" .Item(sch & "sendpassword") = "mypassword" .Item(sch & "smtpusessl") = 1 .Update Code (markup): I dont know which port to use.... 465? In any case i think this might be more the type of thing you want. Cheers m8
<% sch = "http://schemas.microsoft.com/cdo/configuration/" Set cdoConfig = CreateObject("CDO.Configuration") With cdoConfig.Fields .Item(sch & "sendusing") = 2 ' cdoSendUsingPort .Item(sch & "smtpserver") = "smtp.gmail.com" .Item(sch & "smtpauthenticate") = 1 '.Item(sch & "sendusername") = "rag84dec@gmail.com" '.Item(sch & "sendpassword") = "mypassword" .update End With Set cdoMessage = CreateObject("CDO.Message") With cdoMessage Set .Configuration = cdoConfig .From = "rag84dec@gmail.com" .To = "rag84dec@gmail.com" .Subject = "Sample CDO Message" .TextBody = "This is a test for CDO.message" .Send End With Set cdoMessage = Nothing Set cdoConfig = Nothing %> Code (markup): getting the same error.... at the same line please help
I just wrote this and successfully sent myself a message: MailMessage mailItem = new MailMessage(); mailItem.To = "me@gmail.com"; mailItem.Subject = "hi this is a test"; mailItem.From = "me@gmail.com"; mailItem.Body = "hi this is a test message"; SmtpMail.SmtpServer = "smtp.gmail.com"; mailItem.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 465); mailItem.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1); mailItem.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "me@gmail.com"); mailItem.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "myPassword"); mailItem.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true"); SmtpMail.Send(mailItem); Code (markup): try maybe adding: .Item(sch & "smtpusessl") = true //(or "true"? or 1?) Code (markup): let me know if that works for you goodluck