Options

Navision data type to handle recordset

oclistoclist Member Posts: 20
edited 2005-07-28 in Navision Attain
Hi all,

I just found this site and I love it! I've been struggling to find Navision resources on the web to help me and it's like I've hit the jackpot! My problem is...

(history: you can skip this part)
I've been playing with various ways of sending email from Navision. I've done.
1) shell command to mailto: url, which worked ok but I couldn't get the body to support a navision:// hyperlink.
2) then I used Outlook Automation to send an email and that seemed to work except it popped up a message box askng to allow Navision to send email through outlook.
3) then I thought about using the SMTP OCX module but I didn't want to have to install the OCX file to all the client computers or have to share it out on a network drive.
4) which brings me to ....

I'm trying to send an email out using CDO for windows 2000 (which is preinstalled on windows 2000 and windows XP). I believe I'm almost there. The only problem I'm having is that I don't know how to handle the ADOBE recordset which consists of name/value pairs in Navision.

The CDO.IConfiguration FIELDS method returns a recordset with name/value pairs. I'm not sure how to code Navision to handle the name/value pairs.

Any help would be appreciated. :)
Thanks!

The following code doesn't work but here it is...

IF ISCLEAR(objEmailConf) THEN CREATE(objEmailConf);
Flds := objEmailConf.Fields; '<--- not sure what datatype to use for Flds

Flds('sendusing') := 2; '<--- not sure how to set the name/value pairs
Flds('smtpserver') := 'exchange';
Flds('smtpserverport') := 25;
Flds.Update;

IF ISCLEAR(objEmail) THEN CREATE(objEmail);
objEmailIMsg := objEmail;
objEmailIMsg.From := 'test@blah.com';
objEmailIMsg."To" := 'blah@blah.com';
objEmailIMsg.Subject := 'TEST';
objEmailIMsg.TextBody := 'test';
objEmailIMsg.Send;

Comments

  • Options
    rrhodes77rrhodes77 Member Posts: 8
    Have you thought about using products like pdf995 that allow you to configure it like a printer and set it up so that when you print an invoice, order ack, etc. it is put into pdf format and automatically attached to an email?

    We use it for Purchase Orders today and it works well. Another product would be win2pdf which has similar functionality.
    Work smarter, not harder!
  • Options
    oclistoclist Member Posts: 20
    Thanks for info. I'll keep that idea in mind for our ordering process but I'm actually trying to improve the email function on the PO approval form I wrote, which is only used internally.
  • Options
    fbfb Member Posts: 246
    Define 'flds' as 'Microsoft ActiveX Data Objects 2.x Library'.Fields.
    Define 'fld' as 'Microsoft ActiveX Data Objects 2.x Library'.Field.

    Then assign the values as follows:
    fld := flds.Item('smtpserver');  // get the fld from the collection...
    fld.Value('exchange');  // yeah, this is a weird way to assign a value...
    
    fld := flds.Item('smtpserverport');
    fld.Value(25);
    
    fld := flds.Item('sendusing');
    fld.Value(2);
    
    flds.Update();
    
  • Options
    afarrafarr Member Posts: 287
    oclist wrote:
    Hi all,

    I just found this site and I love it! I've been struggling to find Navision resources on the web to help me and it's like I've hit the jackpot!

    You probably know about http://www.navision.net, a sister (or rival :-))site, but I just wanted to mention it to be sure you and other posters knew. Btw, it is occasionally unavailable, like right now :-(.

    Alastair
    Alastair Farrugia
  • Options
    RobertMoRobertMo Member Posts: 484
    For all kinds of emailing I use Jmail (www.dimac.net) - free component. and fully documented.
    you can send email just in 1 line of code, or you can write your own mail client or email distribution center...

    yes, it's an automation server, but I have seen a post which deals how to store a dll as blob in navision and when needed, automatically pull it out and store on client's machine, register it and use it on the fly...

    search the forum (maybe download section)
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    oclistoclist Member Posts: 20
    Thanks for all help everyone. I finally got it to work. With the follow code you should be able to send emails using CDO for windows 2000 (which according to MS... As of December 2003, CDOSYS is an integral part of the Windows 2000, Windows XP, and Windows 2003 series of operating systems.) and Microsoft ActiveX Data Objects 2.5 Library (which should also be already on most machines). This code will allow you to send an email via SMTP without the outlook popup box and without installing additional ocx or other software. Just another option for sending email on machines with new operating systems.

    Define 'objEmailConf' as 'Microsoft CDO For Exchange 2000 Library'.Configuration.
    Define 'objEmail' as 'Microsoft CDO For Exchange 2000 Library'.Message.
    Define 'flds' as 'Microsoft ActiveX Data Objects 2.5 Library'.Fields.
    Define 'fld' as 'Microsoft ActiveX Data Objects 2.5 Library'.Field.

    IF ISCLEAR(objEmailConf) THEN CREATE(objEmailConf);
    flds := objEmailConf.Fields;

    fld := flds.Item('http://schemas.microsoft.com/cdo/configuration/smtpserver');
    fld.Value('mail.yourdomain.com');

    fld := flds.Item('http://schemas.microsoft.com/cdo/configuration/smtpserverport');
    fld.Value(25);

    fld := flds.Item('http://schemas.microsoft.com/cdo/configuration/sendusing');
    fld.Value(2);

    flds.Update();

    IF ISCLEAR(objEmail) THEN CREATE(objEmail);
    objEmail.Configuration := objEmailConf;
    objEmail.From := 'testfrom@yourdomain.com;
    objEmail."To" := 'testto@yourdomain.com';
    objEmail.Subject := 'test subject';
    objEmail.TextBody := 'Test';
    objEmail.Send;
  • Options
    RobertMoRobertMo Member Posts: 484
    I copy pasted the code and it works. (A minor bug: single quote missing to end string)
    objEmail.From := 'testfrom@yourdomain.com;

    I'm running on XP. I had to use:
    'Microsoft CDO for Windows 2000 Library' instead of 'Microsoft CDO For Exchange 2000 Library'
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    oclistoclist Member Posts: 20
    Yup... Thanks for the check RobertMo. I meant to use the CDO for Windows 2000 Library.

    FYI... from MS's website.
    "When you upgrade a computer running Microsoft® Windows® 2000 with Microsoft® Exchange® 2000 server, a new COM component, Microsoft CDO for Exchange 2000 replaces the Microsoft CDO for Windows 2000 component. The CDO for Windows 2000 component is a proper subset of the functionality offered by CDO for Exchange 2000, so all applications, including transport event sinks, will continue to function properly. When Microsoft Exchange 2000 is installed, the CDO for Windows 2000 component is unregistered from the system and COM runtime."

    links to related info I've been using:

    http://msdn.microsoft.com/library/defau ... in2000.asp

    http://msdn.microsoft.com/library/defau ... bjects.asp
  • Options
    RobertMoRobertMo Member Posts: 484
    Great! That sorted out with my fears of possible incompatibility...

    BTW. I'm preparing a "Simple Email Sender" using this functionality. I will probably send it here for the download section. Anybody want's to be a co-author ?
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    tmatejkotmatejko Member Posts: 2
    Hello!

    I have something strange...
    Client with W2k / Navision - without problems.
    Another machine - client with WXP from VBScript - without problems
    but from Navision - error. :(
    I can set Configuration but during Update - Automation Server
    reporting error -2147352567.
    Both machines - the same fin.exe

    Any ideas?

    Regards,
    Tomasz Matejko
  • Options
    goddersgodders Member Posts: 3
    I've used the above code which works fine in most cases but for some users it disables some of their keys eg Backspace, Escape etc and locks the table they are reading whilst sending the email. This is the case until they close the form that is using the code.

    Do the users have to have a specific service pack for Win2000 since it only seems to happen on older machines that dont run XP.
  • Options
    ntnt Member Posts: 160
    oclist wrote:
    Thanks for all help everyone. I finally got it to work. With the follow code you should be able to send emails using CDO for windows 2000 (which according to MS... As of December 2003, CDOSYS is an integral part of the Windows 2000, Windows XP, and Windows 2003 series of operating systems.) and Microsoft ActiveX Data Objects 2.5 Library (which should also be already on most machines). This code will allow you to send an email via SMTP without the outlook popup box and without installing additional ocx or other software. Just another option for sending email on machines with new operating systems.

    Define 'objEmailConf' as 'Microsoft CDO For Exchange 2000 Library'.Configuration.
    Define 'objEmail' as 'Microsoft CDO For Exchange 2000 Library'.Message.
    Define 'flds' as 'Microsoft ActiveX Data Objects 2.5 Library'.Fields.
    Define 'fld' as 'Microsoft ActiveX Data Objects 2.5 Library'.Field.

    IF ISCLEAR(objEmailConf) THEN CREATE(objEmailConf);
    flds := objEmailConf.Fields;

    fld := flds.Item('http://schemas.microsoft.com/cdo/configuration/smtpserver');
    fld.Value('mail.yourdomain.com');

    fld := flds.Item('http://schemas.microsoft.com/cdo/configuration/smtpserverport');
    fld.Value(25);

    fld := flds.Item('http://schemas.microsoft.com/cdo/configuration/sendusing');
    fld.Value(2);

    flds.Update();

    IF ISCLEAR(objEmail) THEN CREATE(objEmail);
    objEmail.Configuration := objEmailConf;
    objEmail.From := 'testfrom@yourdomain.com;
    objEmail."To" := 'testto@yourdomain.com';
    objEmail.Subject := 'test subject';
    objEmail.TextBody := 'Test';
    objEmail.Send;

    Hi all,
    i can test this code in a local pc? i'm using iis with xp.

    thanks.
Sign In or Register to comment.