Aspose.Email Editing Contact "FN:" Field


#1

Hello, I was trying to edit a contact as an MapiContact. When it was created, it had this FN field. I was wondering if there was a way to modify it since the following line of code only added the N field. Setting the display name also worked when output to console (with contact.NameInfo.DisplayName = “something”), but not in the saved file.

contact.NameInfo = new MapiContactNamePropertySet(“test”, “test”, “test”);

Example .vcs file:

BEGIN:VCARD
VERSION:2.1
N:test;test;test
FN:Original Sender1
ORG:Test Org
EMAIL;TYPE=INTERNET:originalsender@test.com
END:VCARD


#2

@awalker1,

We were able to observe the problem with the VCF contact type for updating display name information. It has been logged as EMAILNET-39042 for further investigation at our end. We’ll update you here once there is some information or a fix version available in this regard.

We also noticed that the change is visible if we save the message in MSG format. Sharing just in case it may be of any help to you.


#3

Thank you for confirming it is an issue. For now, what I may be able to do is create a new MapiContact object and recreate the contact with an empty “FN” field if the original vcard did not include first, last, and middle but only had that “FN” field.

I was also wondering the best way to change the “From” header of an MapiContact object even if that included converting to another object.


#4

@awalker1,

Could you please elaborate your requirement in more detail? If possible, please assist us with the help of sample input and expected output files for our reference.


#5

Basically, I ended up creating a new MapiContact object from scratch but am still unable to set that FN field with Aspose if it never had the individual name parts.

I am able to set the subject field like Outlook normally would to file as, but also wanted to know how to set the from field since this does not seem to be an option for MapiContact. This From field may have been set by Outlook once I opened the contact and only had my name, but not an email address.

I guess I would have to convert MapiContact to another object and then back?

Example headers in .eml format of MapiContact:
Message-ID: <809079ec48ac47afbd83eb4d6ad78f1a>
From: “Last, First” <------------------------------------------------------ desired to change
Subject: Modified Sender1(Aspose.Email Evaluation) <--------- was able to change as MapiContact
Date: Tue, 10 Jul 2018 19:26:15 +0000
X-Unsent: 1
MIME-Version: 1.0
Content-Type: multipart/alternative;


#6

@awalker1,

Please give a try to the following code sample and let us know your feedback.

MapiContact contact = new MapiContact("Display name", "address@domain.com", "Company ABC");

MemoryStream ms = new MemoryStream();

contact.Save(ms, ContactSaveFormat.Msg);

ms.Position = 0;

MapiMessage msg = MapiMessage.FromStream(ms);

msg.SenderEmailAddress = "sender@domain.com";

contact = (MapiContact)msg.ToMapiMessageItem();

contact.Save("ContactFromMsg.msg", ContactSaveFormat.Msg);

#7

Thanks for the help, I did notice I can use your method in addition to the code below to modify the sender and could get the result below. I did run into something similar setting a “From” field in a message and this contact was originally sent from an exchange user. I guess I was wondering if it would be possible to change the sender to another exchange user, so basically the from field would just show the display name.

image.png (898 Bytes)

        temp.SenderName = "test, test";
        temp.SenderSmtpAddress = "sender@domain.com";
        temp.SenderEmailAddress = "sender@domain.com";
        temp.SentRepresentingEmailAddress = "sender@domain.com";
        temp.SentRepresentingName = "test, test";

#8

@awalker1,

We are not sure what your actual requirement is. Please assist us with the help of a sample contact and complete scenario that you want to achieve. This will help us assist you further in better way.


#9

The issues you have found earlier (filed as EMAILNET-39042) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by kashif.iqbal


#10

Sorry for the delay, here is a sample contact.

This was created by Outlook as an Exchange user. I was able to access these properties, but I was wondering how to change this contact From field to another exchange user (seems like it would require changing that Exhange ID, but Aspose.Email seems to convert the message as if it was not sent over Exchange when I update any of those sender properties).

I have also noticed the display as field does not look right when using the following code. It seems to duplicate the email address twice.

        MapiMessage mapi = MapiMessage.FromFile(@"C:\temp\PST\Test Contact.msg");
        MapiContact contact = (MapiContact)mapi.ToMapiMessageItem();

        //Console.WriteLine(contact.ElectronicAddresses.Email1.DisplayName);
        //Console.WriteLine(contact.ElectronicAddresses.Email1.EmailAddress);
        contact.ElectronicAddresses.Email1.DisplayName = contact.ElectronicAddresses.Email1.DisplayName.Replace("Test", "Replacement").Replace("test", "replacement");
        contact.ElectronicAddresses.Email1.EmailAddress = contact.ElectronicAddresses.Email1.EmailAddress.Replace("Test", "Replacement").Replace("test", "replacement");

        contact.Save(@"C:\temp\PST\TestContactModded.msg", ContactSaveFormat.Msg);

Test Contact.zip (6.6 KB)


#11

@awalker1,

We were able to observe the issue with DisplayAs field as you have mentioned. However, we need code sample for your above mentioned problem as well to further investigation this. Please help us identify the issue with the help of screenshot and sample code for looking into it further.


#12

2 posts were split to a new topic: Not able to set From field for Contact