Change sender on DocuSign envelope within EnvelopesAPI - c#

I'm sending documents electronically successfully within an app using DocuSign.
Depending on who's logged into the app I was hoping to change the sender email address..so they can get notified of any responses via email.
Is this possible using EnvelopesAPI, I don't have to create an account with each user's email address, do I?
Thanks,

In your c# try adding the below code, This overrides the reply to in an email.
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSettings = new EmailSettings();
envDef.EmailSettings.ReplyEmailAddressOverride = YOUR_LOGGEDIN_USEREMAIL;

Related

Docusign Permissions: Shared Envelopes vs. Shared Access

I have been using the "Shared Envelopes" feature to allow specific users who are not the sender or a recipient of the envelope to be able to view an envelope in my application without any issues. I used the following instructions to do so:
How to embed the DocuSign UI in your app:
https://developers.docusign.com/docs/esign-rest-api/how-to/embed-ui/
This lays out using the SDK method Envelopes::createConsoleView.
However, DocuSign has deprecated "Shared Envelopes" in favor of their new "Shared Access".
I removed the users from the "Shared Envelopes" of the sending account and added them to "Shared Access" of the sending account. Unfortunately, when I make this change the users can no longer view the envelope and receive the following error message:
Error calling CreateConsoleView: {"errorCode":"USER_NOT_ENVELOPE_SENDER_OR_RECIPIENT","message":"This user is not the sender or a recipient of the envelope. Only the sender or a recipient of the envelope may perform the requested operation."}
Here is my code:
//API - EnvelopeViews:createConsoleView
public string GetEnvelopeViewUrl(string accountId, string envelopeId, string returnUrl)
{
var token = _tokenService.FetchToken(accountId);
var apiClient = new DocuSignClient($"{token.Account.BaseUri}/restapi");
apiClient.Configuration.DefaultHeader.Add("Authorization", $"Bearer {token.Value}");
var envelopesApi = new EnvelopesApi(apiClient);
var apiAccountId = _config["DocuSign:ApiAccountId"];
ConsoleViewRequest viewRequest = new ConsoleViewRequest
{
EnvelopeId = envelopeId,
ReturnUrl = returnUrl
};
var recipientView = envelopesApi.CreateConsoleView(apiAccountId, viewRequest);
return recipientView.Url;
}
I know the users in my app are not the sender or a recipient of the envelope. I thought that was the whole point of "Shared Access". Can anyone provide some guidance on how to enable the new "Shared Access" users to be able to view an envelope like they can with the old "Shared Envelopes" in my application?
Baxter, as of right now (November 2022) the new feature for Shared Access is only to support using the web app and does not provide any functionality for developers using the API.
The old feature, like you mentioned, called shared envelopes, was fully supporting the API and the call you made would work with that.
There's a future plan to support the API using Shared Access, but I don't know the details or the date. I can update this answer once I have this information.

Bot Framework - Email Channel To send Email Via Directline C# Bot

I want to use email channel of bot framework to send email via bot if bot is unable to provide help required.
I have configured an outlook office 365 email and successfully added to the email channel of my bot.
As I have never used the email channel before I am not sure of the channel data that has to be set in case of email, I have no idea what is missing or if there's some error in reply creation.
I want to send direct email from bot to user's email id with some relevant details, user to whom email will be sent is not involved in conversation.
I am getting bad request error while trying to send the email via following code:
ChannelAccount botAccount = new ChannelAccount(
id: $"{ConfigurationManager.AppSettings["BotEmail"]}".ToLower(),
name: $"{ConfigurationManager.AppSettings["BotId"]}")
{ Id = ConfigurationManager.AppSettings["BotEmail"]};
ChannelAccount userAccount = new ChannelAccount(
id: $"{ConfigurationManager.AppSettings["UserEmail"]}",
name: "Vanjuli")
{ Id = ConfigurationManager.AppSettings["UserEmail"]};
var serviceURL = #"https://email.botframework.com/";
MicrosoftAppCredentials.TrustServiceUrl(serviceURL, DateTime.MaxValue);
using (var _connector = new ConnectorClient(new Uri(serviceURL)))
{
ConversationResourceResponse conversationId = await _connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount);
IMessageActivity reply = Activity.CreateMessageActivity();
reply.From = botAccount;
reply.Recipient = userAccount;
ConversationAccount conversationAccount = new ConversationAccount(id: conversationId.Id);
reply.Conversation = new ConversationAccount(id: conversationId.Id);
reply.Text = "This is dummy text of an email!";
reply.Locale = "en-Us";
await _connector.Conversations.SendToConversationAsync((Activity)reply);
}
I would also like to send attachments via email and send email to a group (service desk or group of email ids), is it possible to do so via email channel from a bot deployed on website or are there any challenges or risks ?
According to Microsoft documentation bot receives all emails from the registered mail and can reply to any email but what I am trying to achieve is sending email explicitly which is not a reply to any previous mail. Is something like this possible for a bot which is not solely an email chatbot or is deployed on a website?
While the intent is admirable, the approach is not recommended at all, and was not intended to mix the channels in such a manner.
Nicholas is correct; if you want to showcase multiple channels, it's best to not have them in a single

Getting display name from EWS when passing in just an email address

I've using a custom GetMailTips SOAP call (since the EWS for Core 2.0 doesn't support it) to get Out of Office info for a batch of email addresses.
How can I get the display names of the users that I am passing in the email address for?
I can call ResolveName of the managed API and that works but it has to be done one at a time and that is slow. I would like to ideally get this info out when I make my GetMailTips request and failing that make a call with all the email addresses to get the Display Names all at once. I read there is meant to be a ResolveNames method but that's not in the API either.
Any help appreciated
Autodiscover can return that for multiple users eg
AutodiscoverService adService = new AutodiscoverService(ExchangeVersion.Exchange2013_SP1);
adService.Credentials = new NetworkCredential("user#d.com", "pass");
adService.RedirectionUrlValidationCallback = adAutoDiscoCallBack;
List<String> Users = new List<string>();
Users.Add("user1#domain.com");
Users.Add("user2#domain.com");
GetUserSettingsResponseCollection usrSettings = adService.GetUsersSettings(Users, UserSettingName.UserDisplayName);
foreach(GetUserSettingsResponse usr in usrSettings)
{
Console.WriteLine(usr.Settings[UserSettingName.UserDisplayName]);
}
Another way would be to create a Message and add the email address as recipients then save it to the drafts folders and the address should get resolved against the GAL.

Docusign: Is there a way to create an envelope in the 'created' state and then put it into 'sent' later?

I want to be able to create an envelope and then email the link to the signer. The code segment I came up with is:
EnvelopesApi envelopesApi = new EnvelopesApi();
envDef.Status = "sent";
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
RecipientViewRequest viewOptions = new RecipientViewRequest()
{
ReturnUrl = "https://www.docusign.com/devcenter",
ClientUserId = signer.ClientUserId,
AuthenticationMethod = "email",
UserName = signer.Name,
Email = signer.Email // does NOT send an email
};
ViewUrl recipientView = envelopesApi.CreateRecipientView(accountId, envelopeSummary.EnvelopeId, viewOptions);
The code before this segment gets the account, signer an envelope definition, etc.
This code works fine if I set envDef.Status = "sent". If I do not set that status, I get an exception from the last line of code in this segment.
I want to just have the envelope go into created status, then get the URL and send the email in my own code that does relay email.
Or, can I supply an email address and have Docusign send the email? But, in that case, what if their email fails for some reason?
The bottom line is that I want a way to deal with the problem of how to re-send the link if the email fails to get sent.
Re your stated objective:
I want to just have the envelope go into created status, then get the URL and send the email in my own code that does relay email.
This approach is not recommended, since the URL that you obtain via CreateRecipientView will timeout in a short amount of time (I believe it's 5 minutes). In other words, if the recipient does not open the email that you send them and click the link to launch their signing session within that period of time, the link becomes invalid and they'll be unable to use it to access their signing session.
Instead of using CreateRecipientView, I'd recommend that you simply specify the recipient's info (name, email, etc.) as part of the envelope definition and then DocuSign will send the recipient an email that contains a link that they can use to access their Envelope. This link will be valid for days (not minutes, like the link that you generate yourself via CreateRecipientView), so there's no requirement that the signer act on it immediately. If for some reason the recipient misplaces or does not receive the email that DocuSign sends them, you can easily have DocuSign re-send that email notification by either using the DocuSign web UI or by using the UpdateRecipient API operation with resendEnvelope=true specified (as Frederic described in his answer).
Update #1
There's no way to retrieve a long-lived link that a recipient can use to initiate their signing session. A common way to address your scenario would be the following:
Send the signer an email that contains a link that leads them to a web page that you build -- and instructions for them to click that link to launch their Envelope whenever they are ready to review/sign the document(s). (The link URL would need to contain some sort of querystring parameters that your web page could use to identify the Envelope and Recipient.)
Design your web page such that when it receives an inbound request (as it would when the recipient clicks the link in the email you send them), it uses the information in the querystring parameters to identify the Envelope and Recipient, then issues a CreateRecipientView request to retrieve the URL that will launch that recipient's signing session, and finally, automatically redirects the user to the URL that the CreateRecipientView response returns, thereby opening the Envelope for the recipient to review/sign/submit.
By following a process like this, you're able to craft/send the email that the recipient receives (instead of relying upon DocuSign to do so), and can ensure that you're only retrieving the envelope URL whenever the user has indicated that they're ready to sign (thereby avoiding the potential of the short-lived link expiring before it's used).
Update #2
For an example of how to add recipient(s) to the EnvelopeDefinition object using the DocuSign C# SDK, see this "recipe" -- specifically, see the code within the requestSignatureOnDocumentTest method. It's basically a two-step process:
1) Define each recipient. For example:
// Add a recipient to sign the documeent
Signer signer = new Signer();
signer.Email = recipientEmail;
signer.Name = recipientName;
signer.RecipientId = "1";
2) Populate the Recipients property of the EnvelopeDefinition object with the recipient(s) that you create. For example:
envDef.Recipients = new Recipients();
envDef.Recipients.Signers = new List<Signer>();
envDef.Recipients.Signers.Add(signer);
I'm going to try to answer both of your inquiries :
1) The bottom line is that I want a way to deal with the problem of how to re-send the link if the email fails to get sent.
In order to re-send the DocuSign email to your recipients, you can use the UpdateRecipient() method as such (see my C# example below). This will re-trigger the signing email to be sent one more time to the transaction recipients :
RecipientsUpdateSummary recipientsUpdateSummary =
envelopeApi.UpdateRecipients(
accountId,
envelope.EnvelopeId,
envelope.Recipients,
new EnvelopesApi.UpdateRecipientsOptions { resendEnvelope = "true" });
Here is what the official documentation states :
2) Is there a way to create an envelope in the 'created' state and then put it into 'sent' later?
Yes, it is possible.
When you create your envelope, make sure to specify the "Created" status as below :
Status = "created"
Create your envelope :
envelopeApi.CreateEnvelope(accountId, envelope);
Then, when you're ready, change the envelope status to "sent". This will trigger the emails to the recipients. Voila !
Envelope updatedEnvelope = new Envelope
{
Status = "sent"
};
envelopeApi.Update(
accountId,
envelopeId,
updatedEnvelope);

Internet Message ID FROM EWS Managed API Send Email c#

I am trying to discover if there is a way to determine the internet message ID after sending an email using the EWS Managed API. I understand you can go in there and get the results from the sent box, but the server that is sending these emails is sending multiple emails at a time from different services.
No you can't, basically because EWS sends message Asynchronously the Id isn't available see https://social.msdn.microsoft.com/Forums/azure/en-US/dd034b8c-ffa1-4ae0-9025-45fcf520c9e5/updateitem-does-not-return-itemid?forum=exchangesvrdevelopment
As a work around you might want to consider setting the Internet messageId on the Message before you send it. As long as it valid and unique it should work okay eg
ExtendedPropertyDefinition PidTagInternetMessageId = new ExtendedPropertyDefinition(4149, MapiPropertyType.String);
EmailMessage ema = new EmailMessage(service);
ema.Subject ="test from ews";
ema.Body = new MessageBody("test<br>Rgds<>");
ema.ToRecipients.Add("gscales#domain.com");
ema.SetExtendedProperty(PidTagInternetMessageId,("<" +Guid.NewGuid().ToString() + "#domain.com>"));
ema.SendAndSaveCopy();
Also if you save the message first as a draft before sending it the server will assign the MessageId property which which should then be able to read back using Load.
Cheers
Glen

Categories

Resources