-
Notifications
You must be signed in to change notification settings - Fork 566
Send email with binary extended property (voting options) #466
Description
Hi,
I need to send an email with voting options (Yes, No) and after reading the documentation here it seems i have to use the extended property of Binary type with id 0x00008520.
I used the API to retrieve a mail containing voting options i sent with outlook and i used the binary content of the extended property to send a new email. But it's not working, the value of the extended property seems to be always null. Here is the code i used :
ExtendedPropertyDefinition votingButtonProperty = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Common, 0x8520, MapiPropertyType.Binary);
EmailMessage extendedPropertyMail = EmailMessage.bind(service, email.getId(), new PropertySet(votingButtonProperty));
for(ExtendedProperty property : extendedPropertyMail.getExtendedProperties()) {
if(property.getPropertyDefinition().getId().intValue() == 0x8520) {
EmailMessage msg = new EmailMessage(service);
// Set subject and recipients ...
msg.setExtendedProperty(votingButtonProperty, property.getValue());
msg.send();
}
}
When i look at the source code, it seems we cannot add extendedProperty of type byte[] for MapiPropertyType.Binary, it has to be an array of Byte as we can see in MapiTypeConverter.java:
mapitype = new MapiTypeConverterMapEntry(Byte[].class);
mapitype.setParse(IFunctions.Base64Decoder.INSTANCE);
mapitype.setConvertToString(IFunctions.Base64Encoder.INSTANCE);
map.put(MapiPropertyType.Binary, mapitype);
And if i convert the byte array to Byte array before calling msg.setExtendedProperty(votingButtonProperty, property.getValue());, then i get a ClassCastException : Cannot cast Byte[] to byte[] when executing this code (L82 - IFunctions.java) :
public static class Base64Encoder implements IFunction<Object, String> {
public static final Base64Encoder INSTANCE = new Base64Encoder();
public String func(final Object o) {
return Base64.encodeBase64String((byte[]) o);
}
}
Can you tell me if i'm doing this wrong and point me in the right direction ?
Thank you