-3

I have a specific requirement to send the user contact details as a Business Card to Outlook using C#.Net, it works perfectly and sends the Business Cards to Outlook however facing an issue when user name is in unicode format.

Sample-1:
- UserName : Crazy
- It works perfectly and able to view the user name without any issues on the outlook.

Sample-2:
- UserName : Müller
- It sends the business card however it is being displayed as "Müller" on the outlook.

the logic used is:

  1. details will be written into the .vcf file (text file)
  2. the file will be attached in the mail.

code sample:
System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(filePath);
streamWriter.Write(msgStr);
streamWriter.Close();
streamWriter.Dispose();

Attachment _mailAttachment = new Attachment(filePath);
_mailAttachment.ContentDisposition.Inline = true;
mailMessage.Attachments.Add(_mailAttachment);
client.Send(mailMessage);

even tried to encode the content while writing into the file however does not help.

Any help, how can I fix the issue with the unicode formating?

Sample Vcard content:
BEGIN:VCARD
VERSION:2.1
N;CHARSET=UTF-8;LANGUAGE=en:Müller;Alexander
FN;CHARSET=CHARSET=UTF-8;LANGUAGE=en:Müller Alexander
ORG:CEF Corporate Development Office
TITLE:Service Manager
END:VCARD

but still the name is being displayed as "Müller, Alexander"?

One Developer
  • 99
  • 5
  • 43
  • 103
  • what do you mean? should i not ask question here? – One Developer Nov 03 '11 at 14:48
  • tried copy/pasting your sample into notepad and saving as vcf. Worked for me. Maybe try this, and if it works, then check with binary diff, what are differences between files. – PiRX Nov 03 '11 at 15:04
  • Which version of Outlook are you using - the issue may be with that. Outlook 2003 (and maybe 07?) doesn't seem to support unicode by default (though there is a workaround I think). – Dan W Oct 20 '12 at 14:28

2 Answers2

1

You might have a look at the .Net vCard generation library here. It supports what you are trying to do. Also, you have to remember that typically vCard files must be encoded as ASCII, so you'll probably have to convert to ASCII (like QUOTED-PRINTABLE) for it to work.

cjbarth
  • 4,189
  • 6
  • 43
  • 62
0

You need to specify charset for field with unicode characters with

CHARSET=utf-8

For example:

N;CHARSET=utf-8:Müller
PiRX
  • 3,515
  • 1
  • 19
  • 18