1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Simple sending mail fails

Discussion in 'C#' started by rag84dec, Apr 8, 2008.

  1. #1
    Hi i am using the folllowing code to send a simple mail but it is failing i mean it is not sending any mail.I have SMTP installed on my machine...
    
    Set objMessage = CreateObject("CDO.Message") 
    objMessage.Subject = "Subject"
    objMessage.Sender = "some@gmail.com"
    objMessage.To = "some@gmail.com"
    objMessage.TextBody = "e-mail message"
    objMessage.Send
    
    
    
    Code (markup):

     
    rag84dec, Apr 8, 2008 IP
  2. TheCashCow25

    TheCashCow25 Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you get any error message when performing the script? If not, are you sure that the SMTP server you send through accepts the request?
     
    TheCashCow25, Apr 8, 2008 IP
  3. Jhar

    Jhar Peon

    Messages:
    318
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can also try:

    Dim SendResultsTo As String = "some@gmail.com"
    Dim FromEmail As String ="some@gmail.com"
    Dim smtpMailServer As String = "xxxx.yoursmtpserver.com"
    Dim smtpUsername As String = "mail@xyz.com"
    Dim smtpPassword As String = "XXXX"
    Dim MailSubject As String = "Subject"
    Dim MessageBody As String ="e-mail message"
    Dim myMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
    myMessage.To.Add(SendResultsTo)
    myMessage.From = New System.Net.Mail.MailAddress(FromEmail)
    myMessage.Subject = MailSubject
    myMessage.Body = MessageBody
    myMessage.IsBodyHtml = False

    Dim basicAuthenticationInfo As New System.Net.NetworkCredential(smtpUsername, smtpPassword)
    Dim MailObj As New System.Net.Mail.SmtpClient(smtpMailServer)
    MailObj.Credentials = basicAuthenticationInfo
    MailObj.Send(myMessage)
     
    Jhar, Apr 12, 2008 IP
  4. dylanj

    dylanj Peon

    Messages:
    173
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #4
    I'm pretty sure that it's "From", not "Sender". Try this:
    
    Set objMessage = CreateObject("CDO.Message") 
    objMessage.Subject = "Subject"
    objMessage.From = "some@gmail.com"
    objMessage.To = "some@gmail.com"
    objMessage.TextBody = "e-mail message"
    objMessage.Send
    Set objMessage = Nothing
    
    Code (markup):
     
    dylanj, Apr 20, 2008 IP