Sending mail - not working -

ResenderResender Member Posts: 119
Hello all,
Last week I had an assignment where an automatic mail had to be generated.
I tried both using the SMTP & Mail Codeunits.

I either got the error 0x80040213 The transport failed to connect to the server OR
the mail call succeeded but when going into the codeunit at the point where the mail object is to be initiated
the code just stops without an error.

I tried 3 different smtp setting
1)Of the company (both anonymous with my login credentials)
2)Of a public ISP (like gmail, hotmail)
3)Of the ISP of my home account (using login credentials from my account)
All had the same results

I also tried this on a machine with and one without an email client installed.
And in case of the email client I got the error message that the client was unable to do so because it was not set as the default email client, I then looked this error up and did what I've found but the error remained.

I'm currently no longer working on this but I like to know for myself what could have been the cause of this. And how to fix it cause it's been 'bugging' me.

Comments

  • MarkHamblinMarkHamblin Member Posts: 118
    There's no reason I know of that NAV would fail where another client (Outlook, etc.) set up the same way succeeds. So can't really help there. However, if you ever need to interactively send e-mails via NAV (or other app), and don't need to automatically add attachments, you can use the mailto URI. This doesn't actually send the e-mail, it just launches the default mail client, so it's not useful for sending automated alerts, etc.

    To use this approach in NAV, create a variable of type automation with subtype
    'Windows Script Host Object Model'.WshShell
    
    Then a few lines of code to send the e-mail:
    CREATE(oShell);
    oShell.Run('mailto:someguy@somedomain.com&subject=Hello%20There&body=This%20is%20the%20e-mail%20text');
    CLEAR(oShell);
    
    Note that you will likely need to escape the text - if you're in control of it, then you probably only need to worry about putting %20 in place of spaces.

    Sorry I couldn't help with the original issue, but hopefully the mailto approach gives you some other options in the future.

    - Mark
Sign In or Register to comment.