I've written an application that automates the sending of mail from our system via a small console app that i've designed to run in azure as a webjob. The app sends mail perfectly fine until I attempt to add a collection of attatchments. Referring to https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#Createandsendmessages
I've attempted to send their sample code for this with my Attatchments collection containing a single object that looks like this
{
"#odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "menu.txt",
"ContentBytes": "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
However, after this api request was rejected with the error:
{"error":{"code":"RequestBodyRead","message":"The property 'ContentBytes' does not exist on type 'Microsoft.OutlookServices.Attachment'. Make sure to only use property names that are defined by the type."}}
And furthermore spending half an hour on the outlook services support line to fobbed off with go checkout some forums and to read the article I'd been using for reference since I started the project I've thrown in the towel. If anyone can assist me in getting this api to accept the request I'd be eternally thankful.
This is what a sample request looks like.
POST https://outlook.office.com/api/v2.0/me/sendmail
{
"Message": {
"Subject": "Meet for lunch?",
"Body": {
"ContentType": "Text",
"Content": "The new cafeteria is open."
},
"ToRecipients": [
{
"EmailAddress": {
"Address": "garthf#a830edad9050849NDA1.onmicrosoft.com"
}
}
],
"Attachments": [
{
"#odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "menu.txt",
"ContentBytes": "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
]
},
"SaveToSentItems": "false"
}
And I'm aware that the message object has a bool flag of HasAttachments which when set to true does not affect the outcome of the call.
Based on the error message, you were using the ‘Microsoft.OutlookServices.Attachment’ intead of ‘Microsoft.OutlookServices.FileAttachment’.
I can reproduce this issue when I use the ‘Microsoft.OutlookServices.Attachment’ too.
And the sample above which use ‘Microsoft.OutlookServices.FileAttachment’ works well for me.
Please ensure that you were using the ‘Microsoft.OutlookServices.FileAttachment’ to send the text attachment.
Related
So there is another ticket here (closed) that talks about how to do this. However, something must have changed since that ticket was answered.
I followed the very sparse documentation at DocuSign, and keep getting stuck.
I followed another ticket here exactly, and I'm still getting an error that I can't resolve. I do have dozens of different types of calls working perfectly, this is the only call (so far) that I have tried that I can't get to work.
I have a recipient that lost their email. I need to resend to them. No changes to the document are necessary.
I do a 'PUT' to the following URL:
https://na4.docusign.net/restapi/v2/accounts/{Redacted}/envelopes/{Redacted}/recipients?resend_envelope=true
In the body, I pass the object 'DocuSign.eSign.Model.Recipients'
There is 1 recipient, the one who lost the email. (again, status is 'sent', I checked manually to be sure). I included it below for sake of documentation.
I get the following error. I cannot get past this. The error sounds obvious. It sounds like the recipient document is in a status that cannot be resent, but that's simply not the case. I've verified the status, I've verified that account # is correct, I've verified that document id and recipient id are correct. Just not sure what else I can check.
I just need to resend this, and this call should be the right call. According to the documentation, 'PUT' is the correct verb.
{
"recipientUpdateResults": [
{
"recipientId": "1",
"errorDetails": {
"errorCode": "RECIPIENT_UPDATE_FAILED",
"message": "The recipient could not be updated.
Recipient not in state that allows correction."
}
}
]
}
Body of document that is being sent. I've tried both with emailBody & emailSubject NULL, or the original values. Neither way works.
{
"signers": [
{
"email": "{Redacted}",
"emailNotification": {
"emailBody": "{Redacted}",
"emailSubject": "{Redacted}"
},
"name": "{Redacted}",
"recipientId": "1",
"tabs": {
"dateSignedTabs": [
{
"documentId": "1",
"pageNumber": "1",
"recipientId": "1",
"xPosition": "60",
"yPosition": "757"
}
],
"signHereTabs": [
{
"documentId": "1",
"pageNumber": "1",
"recipientId": "1",
"xPosition": "50",
"yPosition": "652"
}
]
}
}
]
}
If the envelope was already sent, meaning it's not longer in "draft" status you cannot simply modify it anymore.
Envelopes can be modified at will only when they are in "draft" state and if your envelope was in that state - you wouldn't get this error.
Once the envelope was sent ("sent" state) you need to use special Correct action for any changes. That can be initiated by putting envelope into correct state and potentially giving user the correct view where they can add/remove recipients and tags.
Update: If you are just trying to resend the envelope, make sure the JSON body of your request is empty ({}). Empty object in C# will do the trick...
Update 2: Need to use REST API v2.1 and not v2.0.
I'm trying to send an activity with an adaptive card attachment and include a mention to the user who created the post. From reading online I found you can't currently include mentions in adaptive cards. Is there a way to mention someone when sending the activity, for example in another attachment?. I have tried setting the activity.Text = mention, this works however it creates two posts, the first with the mention and then another post with the adaptive card as a separate message. I feel there must be a way to do this, else if you created a post and someone responded to you, you'd never know automatically on reply. Also note I'm not using Flow.
Code
Teams Post
Have you thought about (a) sending the adaptive card and (b) sending a "Reply" message to the original Adaptive Card you sent? I haven't done this before, but I'm guessing the id that comes back from turnContext.SendActivityAsync (on the ResourceResponse instance) is the id you can use to "reply" to the message you just created.
Update: I got it working. This is -very- rough code but hopefully enough that you can figure out/adjust to your scenario:
var result = connector.Conversations.SendToConversationAsync([your conversation id], activity).Result;
// I'm re-using the same activity just as a test, you can do whatever (e.g. create a new one)
activity.Text = "Msg 2";
var conversationReference = activity.GetReplyConversationReference(result);
conversationReference.Conversation.Id = conversationReference.Conversation.Id + ";messageid=" + result.Id;
activity.ApplyConversationReference(conversationReference);
connector.Conversations.SendToConversationAsync(conversationReference.Conversation.Id, activity);
So note, really important, you need to change your conversation id to add ";messageid=" to the end, and ADD the reference the message you just posted.
Here's a screenshot:
Hope that helps, and thanks for this - gave me a chance to learn something useful!
Currently Adaptive Card #mention is in developer preview but you can achieve the #Mention in adaptive card with Adaptive card 1.2 version.
You can #Mention a user in adaptive card using following JSON
{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "Hi <at>Mention_Name</at> This is new feature in Adaptive Card version 1.2 Please test..."
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0",
"channelId": {
"entities": [
{
"type": "mention",
"text": "<at>Name</at>",
"mentioned": {
"id": "29:124124124124",
"name": "Mungo"
}
}
]
}
}
You need to specify channelID, and mentioned ID which you can fetch from the activity object itself
On the Slack website, I can format a message like this:
{
"text": "<http://google.com|link to google>"
}
And in the message it will appear like this:
link to google
But I am trying to write a bot and those links aren't working. Using my websocket connection I can send a message like this:
var send = new MessageToSlack()
{
type = "message",
channel = msg.channel,
text = $"http://google.com"
};
ws.SendAsync(JsonConvert.SerializeObject(send), b => { });
And Slack will correctly interpret http://google.com as a link and display it like:
http://google.com
But if I try to send a message with the link in angle brackets with the pipe between the link and the link text (which works on Slack's site) like this:
var send = new MessageToSlack()
{
type = "message",
channel = msg.channel,
text = $"<http://google.com|to google>"
};
ws.SendAsync(JsonConvert.SerializeObject(send), b => { });
I end up with:
<http://google.com|to google>
So how do I get this working from my bot? Why is it not able to parse by links correctly? What am I missing?
As far as I can see from the docs, this should work. Here in the section on formatting messages it says:
The RTM API only supports posting simple messages formatted using our default message formatting mode.
And links to here which does mention links with the pipe character, so I think it should work.
(note MessageToSlack is just an ordinary .NET class with type, channel and text properties that gets serialized by JSON.Net and appears to give the correct JSON. ws is my websocket connection from the WebSocketSharp nuget package)
JSON:
{
"id": 1,
"type": "message",
"channel": "C6QRKT0EA",
"text": "<http://google.com|to google>"
}
Edit: So it seems if I switch from replying with the web socket connection and instead post to https://slack.com/api/chat.postMessage, it will work correctly, but it's a bit more fiddly to use and the documentation led me to believe that the links should work without needing to jump through that particular hoop. Am I just misreading the docs? Or are docs just not very clear on this point?
Try to enable markdown support by adding "mrkdwn": true to your json
{
"type": "message",
"channel": "C6QRKT0EA",
"text": "<http://google.com|to google>",
"mrkdwn": true
}
Read Message Formatting section. Hope it will help.
We are using the GMail Api in a C# application, and have received a message with an embedded image.
You can see the image if you look at the GMail account (in a browser as a user) but I am unable to find it either in the Payload or get an attachment id when I use the api.
Does the api even support accessing embedded images?
If I use:
var part = message.Payload.Parts
.Where(x => x.MimeType.Equals(mimeType))
.Select(x => x.Body.Data)
.FirstOrDefault();
With the Mime type set to Gif,Jpeg or Tiff it always comes back null;
You might want to check the - Users.messages: get
Gets the specified message.
To be familiar on the structure specially when reading the email message Resource representations. I used the Try it now to get the Users.messages resource in the response body and how it will be formed.
When checking the email, the embedded image will fall in the payload.
........
{
"partId": "1",
"mimeType": "image/png",
"filename": "pasted1",
"headers": [
{
"name": "Content-Type",
"value": "image/png; name=pasted1"
},
.........
This is how it should look like.
Hope this helps.
I am working on a task where there are list of 3 people who needs to sign the document one after the other. The very first persons DocuSign the document through the application i.e. its an embedded DocuSign. While the other 2 does remote DocuSign.
I am able to achieve the embedded signing but could not figure out how to achieve the remote signing. Since the envelopeID is same. Even if I add recipients to the envelope the remote DocuSign email is not triggered.
Can anyone help me on how to go about on this?
I would need to see your request body to see how you are adding your recipients, but my guess is that you are setting the latter 2 as embedded also.
To make a recipient an embedded one you need to set the clientUserId property for them, in addition to the other expected info (i.e. email, name, etc). If you do NOT want the recipient to be an embedded one, simply do not set the clientUserId property for them.
For instance, the following (partial) JSON would set the first recipient as an Embedded one and the 2nd and 3rd recipients as remote, meaning will get an email notification to to sign:
"recipients": {
"signers": [
{
"routingOrder": "1",
"recipientId": "1",
"clientUserId": "1000",
"name": "Sally Doe",
"email": "test_1#email.com"
},
{
"routingOrder": "2",
"recipientId": "2",
"name": "John Doe",
"email": "test_2#email.com"
},
{
"routingOrder": "3",
"recipientId": "3",
"name": "Jonny Moe",
"email": "test_3#email.com"
}
]
}
For more information please see the Explore -> Features -> Embedding page on the DocuSign Developer Center:
https://www.docusign.com/developer-center/explore/features/embedding-docusign