0

ブラックベリーのメールに画像を添付するのに問題があります。

私のコードでは、カメラで撮影したpng画像を添付でき、添付ファイルに表示されますが、[メールを送信]ボタンをクリックするとエラーが発生します。

Email service does not support these types of attachments. Change the Send-Using field, or change the attachments

私のコードは次のとおりです。

try {
    FileConnection file = (FileConnection)Connector.open( FILE_NAME );
    if(file.exists())
    {
        InputStream stream = file.openInputStream();
        buf = IOUtilities.streamToBytes(stream);
        stream.close();
        file.close();
        SupportedAttachmentPart sap = new SupportedAttachmentPart(mp,"image/png","collision.png",buf);
        //SupportedAttachmentPart sap = new SupportedAttachmentPart(mp,jpegImage.getMIMEType() ,"collision.jpg",jpegImage.getData() );  
        TextBodyPart tbp = new TextBodyPart(mp,"Attachment test");
        TextBodyPart name = new TextBodyPart(mp,"Name:"+Name.getText().toString());

        mp.addBodyPart(tbp);
        mp.addBodyPart(sap);
        mp.addBodyPart(name);

        Folder folders[] = Session.getDefaultInstance().getStore().list(Folder.SENT);

        Message message = new Message(folders[0]);

        try {
            Address toAdd = new Address("xyz_123@yahoo.com","test email");
            Address toAdds[] = new Address[1];
            toAdds[0] = toAdd;
            message.addRecipients(Message.RecipientType.TO,toAdds);
            message.setContent(mp);
            message.setSubject("Service Request via Blackberry app");

            Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(message));

            //Transport.send(message);
        } 
        catch (Exception e) {
            Dialog.inform(e.toString());
        }
    }
4

1 に答える 1

1

これはシミュレータでは正常です。実際のデバイスで試してみてください。正しく動作します。

于 2010-09-15T16:08:44.483 に答える