Exchange API: Get item with attachment's content - exchange-server

I added an attachment to appointment. But when I try to get appointment by GetItem API method I recieve an appointment without Content node. I don't want to use GetAttachment method because it cost me one additional request to the server. Can I get attachments' content by GetItem method?
<t:Attachments>
<t:FileAttachment>
<t:AttachmentId Id="AAMkADMzZjU2NjIwLWUzOWItNDFlZC1hNDY5LTIwNTVlODdjM2E4YwBGAAAAAAD3/WwqN7V6Saz7jIDwyy6pBwB0enfRGC/+T5l033DSyikwAAAA5OxPAAB0enfRGC/+T5l033DSyikwAAAA5RW8AAABEgAQAMWyPz5NHRZAmn0OqOSsLew=" />
<t:Name>Attachment.xml</t:Name>
<t:ContentType>text/xml</t:ContentType>
<t:Size>125</t:Size>
<t:LastModifiedTime>2013-01-29T08:40:48</t:LastModifiedTime>
<t:IsInline>false</t:IsInline>
<t:IsContactPhoto>false</t:IsContactPhoto>
<t:ContentId />
</t:FileAttachment>
</t:Attachments>

There http://msdn.microsoft.com/en-us/library/exchange/aa565934(v=exchg.80).aspx I have found such information:
The GetItem operation does not return attachments. It does return
metadata about an attached item or file. To return an attachment, use
the GetAttachment Operation.
Question is closed.

Related

How to include an association with a user

I need to return a json object to my view. I see my subscriptions in tinker:
\App\User::find(1)->with('subscriptions')->where('id', 1)->get();
In my view, I get my user data but the subscriptions array is emply (length: 0)
Issue one, why I could not just \App\User::find(1)->with('subscriptions')->get() This returns all users in my database.
How can I return, as json, the current user with subscriptions? The long way is to make two api calls.
Im using Cashier for the subscriptions
Try to check the query log by running
\DB::enableQueryLog();
$data = \App\User::with('subscriptions')->find(1);
$query = \DB::getQueryLog();
dd($query);
It will show you what queries running behind the seens.
then for the json format try to decode into json and then pass to view.
$json_format = json_encode($data);
return view('user.index')->withJsonFormat($json_format);
Don't know why you want to pass the data with json format. but if you want to pass this into javascript, jquery or angular please create saperate API and call with AJAX.
The correct query is:
App\User::with('subscriptions')->find(1)
It will return User object with this user's subscriptions.

Laravel if statement for request object

Currently building out an API. I am working on an update function with excepts the incoming request. so: api.dev.com/?api_key=asdf&storeid=2 etc
now in the backend i am accepting the Request and then i am trying to write some logic to check if the request includes storeid then update that entry etc.
But when i am writing my logic and i do
if(isset($request->storeid))
$store->id = $request->storeid;
If I do not include storeid in my put request then i get:
Call to a member function parameter() on a non-object
Because it is not present. Am I approaching writing this logic the wrong way?
I want to leave it up to the users to update the records they want. So they should not have to include all the variables in the request. Just those that need to be updated.
Citti
Do this instead:
if($request->has('storeid')) {
...
The error "Call to a member function parameter() on a non-object" is not because you are not including the "storeid" input, but because you are not calling an instance of the Store object.
Maybe if you do something like:
if(isset($request->storeid))
$store = Store::findOrFail($request->storeid)

WebAPI and status code 411 "Length Required"

411 Length Required
The request did not specify the length of its content, which is required by the requested resource.
I have the following code:
[HttpPost]
[Route("UploadFileAsync/{RequestID}")]
public async Task<HttpResponseMessage> UploadFileAsync(int RequestID)
{
SetUser();
long maxAllowedFileSize = 9999999;
long? contentLenght = Request.Content.Headers.ContentLength;
if (!contentLenght.HasValue || contentLenght.Value > maxAllowedFileSize)
{
return Request.CreateErrorResponse(HttpStatusCode.LengthRequired, "Please set content lenght and file size should be less than 10 Mb");
}
It works and return 411 status code when size of request is more than 9999999.
But I would like to validate it before uploading the whole request to server (as I understand, sense of this 411 status code to prevent uploading big files if server can't process it). How can I reject request and send 411 status code before sending the whole request to server?
If you want to to validate the size before sending the request to Web API, then you need to do it at Web API client level.
However if you want to perform the validation before the Action in your web api controller is executed, you can use Action Filters. Typically, following steps are involved.
Create custom action filter for the Web API by inherting ActionFilterAttribute class.
Override OnActionExecuting method and write the code to check the content length and return appropriate error code within the method definition.
Register the custom filter in WebApiConfig file.
Decorate the action for which you want to apply this filter with your custom attribute
Refer to this link for step by step implementation.

EWS Edit Attachments in a Forward Email

I'm working on an application that let users manage their emails from a website.
The user can reply to an email as well as forward a an email etc....
My problem is that I want to give the users the ability to remove attachments from
a forward instance of an existing email before sending it.
ResponseMessage response;
response = OriginalEmail.CreateForward(); // create response
ForwardEmail = response.Save(WellKnownFolderName.Drafts);
The ForwardEmail doesn't contain any attachment in the attachments collection.
However when using
ResponseMessage response;
response = this.Email.CreateForward(); // create response
this.Response = response.Save(WellKnownFolderName.Drafts);
this.Response.ToRecipients.Add("me", "me#gmail.com");
this.Response.Send();
I'm getting the attachments in the destination email.
How can I edit the attachments before forwarding?
Thanks in advance
After you call the Save method
ForwardEmail = response.Save(WellKnownFolderName.Drafts);
You should then do Load using a propertySet the specifies you want the attachments returned eg
PropertySet psPropset = new PropertySet(BasePropertySet.FirstClassProperties);
ForwardEmail.Load(psPropset);
That should then populate the Attachment Collection.
Cheers
Glen

virtuemart 2 - how to send invoice as email attachment on confirm order

I want to send invoice as email attachment on order confirmation ,how to go about sending the invoice.
searched a lot ,not relevant data found.
The VM Order Confirmation Email work flow is as follows,
Check the function notifyCustomer() inside orders.php in administrator/components/com_virtuemart/models/
There is a section like shopFunctionsF::renderMail() It calls a function from shopefunctionsf helper file in /components/com_virtuemart/helpers/shopfunctionsf.php
renderMail() calls sendVmMail() in the same file there you can find option for attaching media or anything you want .
if (isset($view->mediaToSend)) {
foreach ((array)$view->mediaToSend as $media) {
//Todo test and such things.
$mailer->addAttachment($media);
}
}
Hope its helps..

Resources