How to set extended properties of the forwarded message using EWS API? - api

I'm using EWS api and I whant to forward email message with addition internet headers.
This is how I forward email message:
// emilMsg is of type EmailMessage
ResponseMessage forwardMsg = emailMsg.createForward();
forwardMsg.send();
The main problem that "createForward" returns object of type ResponseMessage. I know how to add extended properties in EmailMessage, but what about ResponseMessage?

What you can do is, first save ResponseMessage that would give you an EmailMessage, then set extendedProperties in that :-)
Something like this ::
emailMessage = responseMessage.save();
UUID yourPropertySetId = UUID.fromString("01638372-9F96-43b2-A403-B504ED14A910");
ExtendedPropertyDefinition propertyDefinitionBase = new ExtendedPropertyDefinition( yourPropertySetId,
"MyProperty",
MapiPropertyType.String);
emailMessage.setExtendedProperty( propertyDefinitionBase, "MyValue" );
emailMessage.send();

Related

Error when sending message to Bloomberg via QuickFixJ

I'm trying to sending packet type X to Bloomberg via QuickFixJ. I'm able to connect successfully but when I send the packet, I receive an error message :
8=FIXT.1.1^A9=160^A35=X^A34=4^A49=ARHGBETA^A52=20210915-13:16:04.156^A56=BBGBETA^A1022=****^A22=1^A48=BQ4434677^A268=2^A279=0^A269=0^A270=99.00357818603516^A279=0^A269=1^A270=99.01358032226562^A10=060^A
8=FIXT.1.1^A9=253^A35=j^A49=BBGBETA^A56=ARHGBETA^A34=4^A52=20210915-13:16:04.380^A45=4^A372=X^A380=0^A58=Validation failed for incoming X packet:
In mDIncGrp: In groupMDEntries[0]: NULL component instrument_MarketData
In groupMDEntries[1]: NULL component instrument_MarketData
And yet, I don't see how to define the component instrument_MarketData. I'm using the following code to generate the groups:
/**
* Méthode de création d'un nouveau prix pour le publier sur Bloomberg
* #param marketPrice
* */
public MarketDataIncrementalRefresh createMarketDataIncrementalRefresh(MarketPrice marketPrice) {
quickfix.fix50sp2.MarketDataIncrementalRefresh message = new MarketDataIncrementalRefresh();
quickfix.fix50sp2.MarketDataIncrementalRefresh.NoMDEntries group = new MarketDataIncrementalRefresh.NoMDEntries();
message.getHeader().setString(1022, "****");
quickfix.fix50sp2.component.MDIncGrp mdIncGrp = new MDIncGrp();
mdIncGrp.setString(48, marketPrice.getCUSIP());
mdIncGrp.setString(22, "1");
Instrument instrument =new Instrument();
/**
* Ajout prix Bid au message
* */
instrument.setString(279, "0");
instrument.setString(269, "0");
instrument.setString(270, marketPrice.getBid_kech().toString());
group.set(instrument);
mdIncGrp.addGroup(group);
/**
* Ajout prix Ask au message
* */
instrument.setString(279, "0");
instrument.setString(269, "1");
instrument.setString(270, marketPrice.getAsk_kech().toString());
group.set(instrument);
mdIncGrp.addGroup(group);
message.set(mdIncGrp);
return message;
}
What am I doing wrong? Should I define a custom dictionary to be able to send the message or can I do it with the default dictionary?
Many thanks in advance !
You do not need a custom dictionary to send custom messages. Dictionary validation is only done for received messages, so you might need to alter your dictionary to successfully receive the responses sent by your counterparty.
As to your problem: the error sounds as if something is missing in your group regarding the instrument. Looking at your code I think you mix up the group stuff a bit. I posted this link for an earlier question of you: https://www.quickfixj.org/usermanual/2.3.0/usage/repeating_groups.html
I think the important part is that you should add the group to the message like so:
quickfix.fix42.MarketDataSnapshotFullRefresh.NoMDEntries group =
new quickfix.fix42.MarketDataSnapshotFullRefresh.NoMDEntries();
group.set(new MDEntryType('0'));
group.set(new MDEntryPx(12.32));
group.set(new MDEntrySize(100));
group.set(new OrderID("ORDERID"));
message.addGroup(group); // important part
In your code you are adding a group to a group (mdIncGrp.addGroup(group)) and do a message.set(mdIncGrp) where you really should use addGroup(). Because of this the 48/SecurityID field does not end up in the MDIncGrp but the root message.
8=FIXT.1.1^....removed...^A22=1^A48=BQ4434677^A268=2^A279=0^A269=0^A270=99.00357818603516^A279=0^A269=1^A270=99.01358032226562^A10=060^A
^^^ 48 is here where it should really
be in each of these groups starting with delimiter tag 279

Using Google Apps script, how to check if an email has a pdf attached to it, then forward it to another email address?

I managed to create a function that converts an email to a pdf and then it forwards it to another email address ( I used this great library made by Mike Greiling :https://github.com/pixelcog/gmail-to-pdf).
but now I want to create another function that checks if the email already has an attachment, and then forward it right away.
here's my working function:
function saveExpenses() {
GmailUtils.processStarred( 'label: test', 5, function(message) {
// create a pdf of the message
var pdf = GmailUtils.messageToPdf(message);
// prefix the pdf filename with a date string
pdf.setName(GmailUtils.formatDate(message, 'yyyy/MM/dd - ') + pdf.getName());
// send confirmation email to the original sender
var confirmationEmail = message.getFrom();
// Get the name of the document to use as an email subject line.
var subject = pdf.getName();
var body = "This is a confirmation that this receipt has been sent";
// Send a confirmation email to the sender
GmailApp.sendEmail(confirmationEmail, subject, body, {attachments: [pdf]});
return true;
});
}
}
Ok, I found the solution, actually it was pretty easy.
I guess I didn't think enough, so basically I just get all the attachments from the message with the function getAttachmentswhich returns an array of attachments, I then just check if the length of the array is greater than 0 ( which means there are attachments in the email )
and if the result is 0, it means there are no attachments.
Here is what I did :
var attachment = message.getAttachments();
if (attachment.length > 0 ) {
// I add the code to deal with the attachment
} else if (attachment.length == 0 ) {
// I add the code that I posted in the question above
}

How to extract data from Message and display it in Notification(Android)

I used GCM(Google Cloud Message) for push notification.
When Notification Arrived on Device It looks Like this :
Received: Bundle[{message=hello, android.support.content.wakelockid=2,
collapse_key=do_not_collapse, from=243316392621}]
Now I wanted to extract message and wakelockId in such a way that Only message displayed on notification.(In this example only hello)
Here my notificationBuider is as below :
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(com.example.example.R.drawable.icon)
.setContentTitle("Example")
.setDefaults(Notification.DEFAULT_ALL)
.setAutoCancel(true)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(msg))
.setContentText(msg);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
Please Guide me on this.Any help will be appreciated.
Based on the notification you got, I'm assuming that msg is of type Bundle and its value is intent.getExtras() where intent is the intent of the GCM BroadcastReceiver.
You should extract the relevant parameter from it :
String text = msg.getString ("message");
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(com.example.example.R.drawable.icon)
.setContentTitle("Example")
.setDefaults(Notification.DEFAULT_ALL)
.setAutoCancel(true)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(text))
.setContentText(text);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
Recibido: Bundle [{mensaje = hola, android.support.content.wakelockid = 2,
collapse_key = do_not_collapse, desde = 243316392621}]
In this way is that google send your data which you have defined in your application server you must do is read this data individually something like
extras.getString ("message")
where message is the data that has defined the key value of your server application

Adobe Echo Sign Sending PDF file

I am working on Adobe Echo sign,I have downloaded the sample code from their website, I am using this sample code for sendingdocument, it has some code missing in sendDocument method so I have changed it. It's giving SoapHeader Exception,with nothing in InnerException,
{"apiActionId=XHZI4WF4BV693YS"}
below is my code of sending document
public static void sendDocument(string apiKey, string fileName, string recipient)
{
ES = new EchoSignDocumentService16();
FileStream file = File.OpenRead(fileName);
secure.echosign.com.FileInfo[] fileInfos = new secure.echosign.com.FileInfo[1];
fileInfos[0] = new secure.echosign.com.FileInfo(fileName, null, file);
SenderInfo senderInfo = null;
string[] recipients = new string[1];
recipients[0] = recipient;
DocumentCreationInfo documentInfo = new DocumentCreationInfo(
recipients,
"Test from SOAP: " + fileName,
"This is neat.",
fileInfos,
SignatureType.ESIGN,
SignatureFlow.SENDER_SIGNATURE_NOT_REQUIRED
);
DocumentKey[] documentKeys;
senderInfo = new SenderInfo(recipient, "password", "APIKEY");
documentKeys = ES.sendDocument(apiKey, senderInfo, documentInfo);
Console.WriteLine("Document key is: " + documentKeys[0].documentKey);
}
its giving exception on this line
documentKeys = ES.sendDocument(apiKey, senderInfo, documentInfo);
Can anyone suggest some sample code of Adobe Echo Sign?
On the account page of your login there is an API log you can check. If you check the log entry for your request you may find more information there.
I can't see anything immediately wrong with your code however the EchoSign API guide says that the 'tos' field is deprecated and that the recipients field should be used instead. Helpfully this means you can't use the paramaterised constructor. Try creating your document creation info as such (this is C# but if you need Java it should be straightforward to figure out):
RecipientInfo[] recipientInfo = new RecipientInfo[1];
recipientInfo[0] = new RecipientInfo
{
email = "recipient",
role = RecipientRole.SIGNER,
roleSpecified = true
};
DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo
{
recipients = recipientInfo,
name = "Test from SOAP: " + fileName,
message = "This is neat.",
fileInfos = fileInfos,
signatureType = SignatureType.ESIGN,
signatureFlow = SignatureFlow.SENDER_SIGNATURE_NOT_REQUIRED
};
Note that when using the recipientInfo array it seems that the roleSpecified field must be set to true. This little field tripped me up for ages and I was receiving errors similar to yours.

WCF Client access with Message Contracts

I have a web service , i add some extra class which have message contract and after that it changed the way we access some of the methods( and i have not added message contract to these classes these are data contracts ), earlier i.e before we could create one object for request and response (like see the Before part) we are creating a single object for OrderStatusResponse Class. But if you see now the After(we have to create separate objects for request and response).
is this a side effect of enabling "Always generate message contract?"
Before
SmartConnect.Service1Client Client =
new SmartConnectClient.SmartConnect.Service1Client();
SmartConnect.OrderStatusResponse Status =
new SmartConnectClient.SmartConnect.OrderStatusResponse();
Status.UserID = "1234";
Status.Password = "abcd";
Status.SoftwareKey = "abc";
Status.OrderNumber = "1234";
Status = Client.GetOrderStatus(Status);
lbl_OS.Text = Status.Status.ToString();
lbl_RM.Text = Status.ReturnMessage.ToString();
After
SmartConnectRepublic.SmartConnectClient SmartClient =
new WCF_Client.SmartConnectRepublic.SmartConnectClient();
//SmartConnectRepublic.OrderStatusResponse Status =
new WCF_Client.SmartConnectRepublic.OrderStatusResponse();
WCF_Client.SmartConnectRepublic.GetOrderStatusRequest request =
new WCF_Client.SmartConnectRepublic.GetOrderStatusRequest();
request.status = new WCF_Client.SmartConnectRepublic.OrderStatusResponse();
request.status.OrderNumber = "1055055";
request.status.UserID = "1234";
request.status.Password = "dfsdfsd";
request.status.SoftwareKey = "sdfsdfsdfs";
WCF_Client.SmartConnectRepublic.GetOrderStatusResponse response =
new WCF_Client.SmartConnectRepublic.GetOrderStatusResponse();
response = SmartClient.GetOrderStatus(request);
lbl_Status.Text = response.GetOrderStatusResult.Status;
lbl_RC.Text = response.GetOrderStatusResult.ReturnCode.ToString();
lbl_RM.Text = response.GetOrderStatusResult.ReturnCode.ToString();
Yes, I suspect it is a difference with using message contracts. You seem to have figured it out, though.