Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

Send email with binary extended property (voting options) #466

@tlsedev

Description

@tlsedev

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions