Results 1 to 11 of 11

Thread: Help with objmessage email sending using authentication

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    145

    Help with objmessage email sending using authentication

    Hi all, back again!

    My host have changed authentication on their email server which has affected this script in my program. My emails now come back as undelivered. The script worked previous to these changes, so I am looking at this part of the code only (there is more code of course, but I am guessing this is where I need to make changes..


    Code:
    objmessage.TextBody = emailbody
        objmessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        objmessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        objmessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]"
        objmessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
        objmessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "my.smtp.server"
        objmessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        objmessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 0
        objmessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
        objmessage.Configuration.Fields.Update
        objmessage.Send
    Thanks in advance

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Help with objmessage email sending using authentication

    "My host have changed authentication" - what changes have they made ?

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Help with objmessage email sending using authentication

    If they actually are returned as undeliverable you have an entirely different kind of problem. It means the To address is wrong or a server along the path to the destination rejected the message.

    Looking at the full headers of the bounced email might tell you why.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    145

    Re: Help with objmessage email sending using authentication

    This is what I get:

    host
    x said: 551 This mail server requires
    authentication before sending mail from a locally hosted domain. Please
    reconfigure your mail client to authenticate before sending mail. (in reply
    to MAIL FROM command)

  5. #5
    Addicted Member
    Join Date
    Jul 2010
    Posts
    158

    Re: Help with objmessage email sending using authentication

    Hi,

    Looks like you have not specified the Recipient...

    Code:
    objmessage.From = txtFrom.Text
    objmessage.To = txtTo.Text
    objmessage.Subject = "Whatever.. Subject..."
    objmessage.TextBody = eMailBody
    Regards
    Veena

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    145

    Re: Help with objmessage email sending using authentication

    Hi Veena, thanks for responding.

    Apologies, I did not include more of the code further above, the recipient is included. I do not have access to the code from work, but will repost it all later, I only included that part as I assumed thats where the error would be.

    Thanks again.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    145

    Re: Help with objmessage email sending using authentication

    This is the rest of the code for this part

    Code:
    Set omsg = CreateObject("cdo.message")
    Set omsg = Nothing
    Set objmessage = CreateObject("CDO.Message")
    ' START EDIT HERE
        objmessage.Subject = "my subject"
        objmessage.From = "my email address"
        objmessage.To = "destination emial address"
        anotherday = Now
        emailbody = "message body"

  8. #8
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Help with objmessage email sending using authentication

    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  9. #9
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Help with objmessage email sending using authentication

    You may find that your mail relay demands POP-before-SMTP authentication now. You can't do this via CDO.

    You'd need to authenticate via a POP3 connection first, and then for a small window of time the SMTP server will accept a connection from the same IP address. Sometimes this SMTP connection requires authentication too, but generally not.

    This is meant to defeat people using SMTP bots and exploiting mail servers as relays, though many have simply accommodated to the new requirement.

  10. #10
    Addicted Member
    Join Date
    Jul 2010
    Posts
    158

    Re: Help with objmessage email sending using authentication

    Hi,

    Entire code looks OK to me... I use similar code for GMail SMTP.. and it works perfectly..

    without VB6, can you send/receive mails with your SMTP directly (I mean thru browser)...?

    Regards
    Veena

  11. #11
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Help with objmessage email sending using authentication

    as suggested by veena, if you can no longer send via your default smpt server, try some free smpt server, like gmail or gmx, both work with cdo, settings posted in this forum, there are others
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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