How to Send Emails through Code Unit

ckndr47ckndr47 Member Posts: 100
Hi,

I want to send email through my code unit, but i dont want to use MS Exchange or Outlook for that; that means i want my code unit to send emails internally without using any tool like outlook.

Please provide me that OCX and also sample code if you have. I need to do tht in a very short time.

Thanks in Advance,

Comments

  • flfl Member Posts: 184
    Hi,

    I had the same problem a few months ago. So, I looked around and I found a file blat.exe on www.blat.net. This is infact a smtp mailer which you can use for free. I even changed my mail codeunit so that this file is allways used instead of outlook. It works very fine and very quickly.
    Francois
    Consultant-Developper

    http://www.CreaChain.com
  • krikikriki Member, Moderator Posts: 9,118
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Have you looked at the downloads of this site?

    SMTP Mail v1.6 - Stabilized
    SMTP OCX v1.6
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • ckndr47ckndr47 Member Posts: 100
    I am using ocx provided by SMTP Mail v1.6 - Stabilized.

    But that email stuff is not working; i am unable to figure out what exactly the problem is becuase with same SMTP Host name i am sending emails from my webbased application and its working fine. But over here i have no clue. This is wht i have written inside my codeunit, please guide me up if i am missing out anything.

    smtp.NewMessage('me@mysmtpdomain.com','Testing');
    smtp.SetToAdress('testuser@test.com');
    smtp.SetFromAdress('me@mysmtpdomain.com');
    smtp.SetHost('MYHOSTNAME');
    smtp.Send(); 
    MESSAGE('%1',smtp.Send()); // this message is returning NO
    MESSAGE('%1',smtp.WasSuccessful()); // this message is returning YES
    MESSAGE('%1',smtp.LastError()); // this message is return nothing
    

    Thanks in Advance
  • PhennoPhenno Member Posts: 630
    ckndr47 wrote:
    I am using ocx provided by SMTP Mail v1.6 - Stabilized.

    But that email stuff is not working; i am unable to figure out what exactly the problem is becuase with same SMTP Host name i am sending emails from my webbased application and its working fine. But over here i have no clue. This is wht i have written inside my codeunit, please guide me up if i am missing out anything.

    smtp.NewMessage('me@mysmtpdomain.com','Testing');
    smtp.SetToAdress('testuser@test.com');
    smtp.SetFromAdress('me@mysmtpdomain.com');
    smtp.SetHost('MYHOSTNAME');
    smtp.Send(); 
    MESSAGE('%1',smtp.Send()); // this message is returning NO
    MESSAGE('%1',smtp.WasSuccessful()); // this message is returning YES
    MESSAGE('%1',smtp.LastError()); // this message is return nothing
    

    Thanks in Advance

    You have to set few more parameters...

    On a example from http://www.nowecor.de/users/stephan/ind ... mtpocx.htm

    here is a minimum of coding for successfull email sending (at least it worked for me).
    SMTPMail.NewMessage('stephan.stapel@tu-clausthal.de','Subject of the mail');
          SMTPMail.SetWorkMode();
    
         SMTPMail.SetHost('gb');
         SMTPMail.SetUserID('coolesau');
    
         SMTPMail.AddLine('This is a test.');
         SMTPMail.AddLine('The second line.');
         SMTPMail.AddLine('Third line');
         SMTPMail.AddAttachment('c:\test.txt');
         SMTPMail.SetToAdress('stephan.stapel@tu-clausthal.de');
         SMTPMail.Send;
    
         IF NOT SMTPMail.WasSuccessful THEN
           MESSAGE(SMTPMail.LastError);
    

    As you can see, you missed SetUserID parameter (which is required) and if you are testing, you should at least put one line of text (body)
  • krikikriki Member, Moderator Posts: 9,118
    We are using it at a customer and it works fine.
    The code we use is like this:
    ocxSmtpMailXElement.NewMessage("E-Mail Address","Subject");
    ocxSmtpMailXElement.SetWorkMode();
    ocxSmtpMailXElement.SetHost("Email Host");
    ocxSmtpMailXElement.SetUserID("E-Mail User ID");
    ocxSmtpMailXElement.AddLine("Body Line");
    ocxSmtpMailXElement.SetToAdress("To email");
    ocxSmtpMailXElement.AddCCRecipients("CC email");
    ocxSmtpMailXElement.AddBCCRecipients("BCC email");
    ocxSmtpMailXElement.AddAttachment("Filename");
    ocxSmtpMailXElement.Send;
    IF NOT ocxSmtpMailXElement.WasSuccessful THEN BEGIN
    END;
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ckndr47ckndr47 Member Posts: 100
    Thanks a million, both codes are working fine.
    So nice of you.

    Regards,
  • PhennoPhenno Member Posts: 630
    I'm having trouble to send mail with this OCX but with From parameter .

    I must give it only real mail address (something@something.com). I SMTP communication I can give in a header a "From: My Name <somethin@something>" line and with that I can send mail with more descriptive From field...


    Has anybody managed to send a more descriptive From field with this OCX?
  • ckndr47ckndr47 Member Posts: 100
    Interesting post Phenno

    I have tried the same over here just for testing purpose and its not working. [/b]
  • PhennoPhenno Member Posts: 630
    ckndr47 wrote:
    Interesting post Phenno

    I have tried the same over here just for testing purpose and its not working. [/b]

    well, I have to say that, althought it's working perfectly what it should work, lack of options gives me no other option than to search for another solution. Or to turn on a Delphi and update ocx :)
  • ckndr47ckndr47 Member Posts: 100
    lack of options gives me no other option than to search for another solution

    Allright then do update :P, if you find any other solution .
    Thanks
  • flfl Member Posts: 184
    Once again, look at http://www.blat.net/syntax/syntax.html. This utility has much options.
    Francois
    Consultant-Developper

    http://www.CreaChain.com
  • PhennoPhenno Member Posts: 630
    fl wrote:
    Once again, look at http://www.blat.net/syntax/syntax.html. This utility has much options.

    Thx, I appriciate that.
  • najlamthnajlamth Member Posts: 18
    Dear All,,,
    I have an error message exist "SMTP error. Error number 10061" when I use SMTP Mail v1.6 - Stabilized and the same code; Can any body help me to fix this problem???
    Regards :)
    Master Navision Developer
  • MaciMaci Member Posts: 65
    Same error!

    After years working fine with the OCX, today I have 2 new clients that give me the "SMTP error. Error number 10061", but same codeunit works fine in other computers!! ](*,)

    Where is the error?

    (EDIT) : I use smtpmailxcontrol 1.6 stabilized

    Thanks
Sign In or Register to comment.