Export Navision Contact as vCard for Lotus Notes, Outlook...

The_GeepzThe_Geepz Member Posts: 17
edited 2008-10-09 in NAV Tips & Tricks
Export Navision Contact as vCard for Lotus Notes, Outlook, The Bat, Applebook, Mozilla etc...

The only thing you need is a simple function - let's call it GetVCard() - returning a string containing vCard-version of the current contact. Idealy we place this function directly on Table 5050, Contact. This function could look as follows.
GetVCard() tResult : Text[1024]
// Prepare CR Characters
c10 := 10;
c13 := 13;
ltEndline := FORMAT(c13) +  FORMAT(c10);
// Open vCard v2.1
tResult := 'BEGIN:VCARD' + ltEndline;
tResult += 'VERSION:2.1' + ltEndline;
// Name
IF Type=Type::Person THEN BEGIN
  tResult += STRSUBSTNO('N:%1;%2;%3;%4;'+ltEndline,Surname,"First Name","Middle Name","Job Title");
  // Title
  IF lrOrgLevel.GET("Organizational Level Code") THEN
    tResult += STRSUBSTNO('TITLE:%1'+ltEndline,lrOrgLevel.Description);
END ELSE
  tResult += STRSUBSTNO('N:%1;%2;;;'+ltEndline,Name,"Name 2");
// Full Name
tResult += STRSUBSTNO('FN:%1'+ltEndline,Name);
// Organization/Company
tResult += STRSUBSTNO('ORG:%1'+ltEndline,"Company Name");
// Phone Nos.
tResult += STRSUBSTNO('TEL;WORK;VOICE:%1'+ltEndline,"Phone No.");
tResult += STRSUBSTNO('TEL;WORK;FAX:%1'+ltEndline,"Fax No.");
tResult += STRSUBSTNO('TEL;CELL;VOICE:%1'+ltEndline,"Mobile Phone No.");
// E-Mail
tResult += STRSUBSTNO('EMAIL;PREF;INTERNET:%1'+ltEndline,"E-Mail");
// URL
tResult += STRSUBSTNO('URL;WORK:%1'+ltEndline,"Home Page");
// Address
tResult += STRSUBSTNO('ADR;WORK;PREF:;;%1;%2;%3;%4;%5'+ltEndline,Address,City,County,"Post Code","Country Code");
// Close vCard v2.1
tResult += 'END:VCARD'+ltEndline+ltEndline;

Simple. That's all. Now we can for example give the user possibility to export currect contact directly on Form 5050, Contact Card. We just add some MenuItem with code like this:

CONTROL1104804 - OnPush()
// Get some File Name
ltFName := cuCDMgt.OpenFile(lTxt001,Name+'.vcf',4,lTxt002,1);
IF ltFName = '' THEN
  EXIT;
// Open Export Stream
CLEAR(lfExport);
lfExport.TEXTMODE(TRUE);
IF NOT lfExport.CREATE(ltFName) THEN
  ERROR(lErr001,lrLNSetup.ToUnixPath(ltFName));
// Write it out;
lfExport.WRITE(cuCDMgt.Ascii2Ansi(GetVCard));
// Close Export Stream
lfExport.CLOSE;

I guess, there is no need to explain any other details and parts of this code. Original post could be found at http://drabek.info/blog/blog.php?bid=15, its German mutation at http://drabek.info/blog/blog.php?bid=16.

Enjoy it! :mrgreen:
The Geepz

Comments

  • ajhvdbajhvdb Member Posts: 672
    Lovely, no synchronization, good example of KISS.

    If you open it with hyperlink, Outlook will open it automatically.
  • kribokribo Member Posts: 12
    question can you post a link to an object we can import?
    Or post a list of the variable declairation
    thnx
  • kribokribo Member Posts: 12
    question??

    lfExport.WRITE(cuCDMgt.Ascii2Ansi(GetVCard));

    cuCDmgt = codeunit Common Dialog management , yes ?
    the function Ascii2Ansi ???

    And is there and import of vCard function ?
  • Jameson05Jameson05 Member Posts: 2
    edited 2019-01-08
    There are many solutions to convert VCF file into outlook. But depends on the number of contacts. As you have mentioned, that you want to convert multiple VCF files into outlook then, manually you can transfer the data from Import and Export settings.

    More :- Import VCF to Outlook
Sign In or Register to comment.