getting preferences for ReadReceiptRequested and OriginatorDeliveryReportRequested from MailItem without triggering Outlook Security Patch - outlook-redemption

I would like to use Redemption library (currently on version 5.27.0.6916) to get preferences for properties ReadReceiptRequested and OriginatorDeliveryReportRequested by creating a new MailItem in Inbox Folder and reading them.
Accessing them via Outlook Object Model (OOM) interop triggers the Outlook Security Patch, resulting in a confirmation dialog/security prompt (strangely enough, this only seems to happen in a terminalserver session).
I tried to use SafeMailItem, but those properties are not implemented.
I have a fallback to read from registry, but is there a way to do this with Redemption?
And is there an explanation for why this would only happen in a terminalserver session?
`
var mailItem = Folders.NewItem<MailItem>(Stores.Get(accountId), DefaultFolders.Inbox);
try
{
return new CMailPreferences
{
DeliveryReceiptRequested = mailItem.OriginatorDeliveryReportRequested,
ReadReceiptRequested = mailItem.ReadReceiptRequested,
};
}
finally
{
Marshal.ReleaseComObject(mailItem);
}
`

You can try to create an instance of the RDOSession object (once, not in a loop) and call RDOSession.GetRDOObjectFromOutlookObject(mailItem) to open the item as RDOMail object.

Related

trying to update signature of a message to be sent

Trying to update signature of a message to be sent (named mailItem, was created by Outlook OOM)
Following code does not seem to work (PP3 is an existing signature)
Redemption.RDOSession rdosession = Redemption.RedemptionLoader.new_RDOSession();
Redemption.RDOMail rdomail = rdosession.GetRDOObjectFromOutlookObject(mailItem);
Redemption.RDOSignatures signatures = rdosession.Signatures;
signatures.Item("PP3").ApplyTo(rdomail, false);
rdomail.CopyTo(mailItem);
What is wrong?
Do you mean mailItem does not see the change? This is to be expected as Outlook does not know it needs to refresh.
Try to create an item from the scratch using Redemption, apply the signature, and only then open it in Outlook using Namespace.GetItemFromID

Wait Until OData Request Completed

I have a requirement to oData service inside onExit hook method. I have written below code but unfortunately oData service is not getting called as view is destroyed immediately . Is there any way to add wait or delay the destroy of view until oData read request is complete ?
window.addEventListener("beforeunload", (event) => {
this.fnUnlockGremienVersion();
var s;
event = event || window.event;
if (this._PreviousGreVersion) {
s = "Your most recent changes are still being saved. " +
"If you close the window now, they may not be saved.";
event.returnValue = s;
return s;
}
});
UI5 has no support for such a workflow and it's not only "UI5", in fact webpages can't block/trap a user within a page for various reasons. Just remember the annoying un-closable webpages from the 2000s. Browser dropped support for such things; except a very simple pop-up api which is supported by UI5.
i assume you are in the shell.
Use the dirty flag properly(set it as long there are unsaved changes or a request still running) and the user will get a popup.
https://sapui5.hana.ondemand.com/sdk/#/api/sap.ushell.services.Container%23methods/setDirtyFlag

Is there a way to preserve a signature in RDOMail.Reply like MailItem.Reply does?

I tried obtaining the reply to the mail by using RDOMail.Reply method.
However, after inspecting the returned object, I've noticed that the signature is not part of the HTMLBody property, as it is when using method MailItem.Reply (which I'm not using because it throws 0x80004004 (E_ABORT) exception). Also, attachments that would be needed for the signature if it contains images are not preserved as they are with MailItem.Reply.
I've tried applying the signature separately, using Signature object. This adds signature to the HTMLBody, but doesn't use the _MailAutoSig attribute to mark the signature part therefore if I select "Change signature" from Outlook Ribbon, signature doesn't get replaced because Outlook has no way of knowing it is a signature.
Is there a way to obtain reply from RDOMail that would contain signature Outlook knows how to replace?
var rdoMail = session.GetMessageFromID(entryid);
var reply = rdoMail.Reply();
reply.HTMLBody = "";
var Account = session.Accounts.GetOrder(rdoAccountCategory.acMail).Item(1);
var signature = Account.ReplySignature;
signature.ApplyTo(reply, false);
reply.Save();
This is a known issue/case when dealing with Extended MAPI code and it is not related to Redemption only. See Messages that are created outside Outlook do not include the default Outlook email signature for more information.
Your choices are:
Mimic the Outlook behavior by adding all the necessary parts like _MailAutoSig attribute to the message body.
Use the Outlook object model with the Reply method and then getting the Redemption equivalent by using the GetRDOObjectFromOutlookObject method. But as far as I can tell, looking at the exception you get, it is not possible because the code is used from a secondary thread, right?
You can use its RDOAccount object (accessible in any language, including VBA). New message signature name is stored in the 0x0016001F property, reply signature is in 0x0017001F.
You can also use the RDOAccount.ReplySignature and NewSignature properties.
Redemption also exposes RDOSignature.ApplyTo method that takes a pointer to the RDOMail object and inserts the signature at the specified location correctly merging the images and the styles:
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Drafts = Session.GetDefaultFolder(olFolderDrafts)
set Msg = Drafts.Items.Add
Msg.To = "user#domain.demo"
Msg.Subject = "testing signatures"
Msg.HTMLBody = "<html><body>some <b>bold</b> message text</body></html>"
set Account = Session.Accounts.GetOrder(2).Item(1) 'first mail account
if Not (Account Is Nothing) Then
set Signature = Account.NewMessageSignature
if Not (Signature Is Nothing) Then
Signature.ApplyTo Msg, false 'apply at the bottom
End If
End If
Msg.Send

NHtmlUnit cannot submit button

I'm discovering about NHtmlUnit to build an application web. But when I try it with auto login to yahoo mail. But after I run code. I refresh the login page of Yahoo so nothing changed. Not logged.
Code:
NHtmlUnit.WebClient driver = new NHtmlUnit.WebClient();
driver.Options.JavaScriptEnabled = true;
driver.Options.ThrowExceptionOnScriptError = false;
driver.Options.ActiveXNative = true;
driver.Options.CssEnabled = true;
HtmlPage page = driver.GetHtmlPage("https://login.yahoo.com/config/login?");
HtmlForm form = page.GetFormByName("login_form");
HtmlTextInput user = (HtmlTextInput)form.GetInputByName("login");
HtmlPasswordInput pass = (HtmlPasswordInput)form.GetInputByName("passwd");
user.SetValueAttribute("my account");
pass.SetValueAttribute("my pass");
HtmlSubmitInput submitButton = (HtmlSubmitInput)page.GetElementByName(".save");
HtmlPage nextpage = (HtmlPage)submitButton.Click();
Please help me why. I write it on .NET MVC 4 C#. Thank you very much.
Only update below single line,due to which u may face class cast exception
HtmlButton submitButton = (HtmlButton)page.GetElementByName(".save");
The code is completely fine, and should works.
Probably the reason you think it is not, is that you check it by a wrong method!
One essential elements which makes a site (i.e. login.yahoo.com) see you as logged in user, is the cookies it provide to your browser/webdriver when you use login forms, so if you use the login procedure by an instance of NHtmlUnit.Webclient (i.e. driver) then you are only logged in inside the driver web client, not inside any other browser or client, even on the same machine.
I tried to add this as a comment, but I don't have enough reputations.

ASP.NET Web API, unexpected end of MIME multi-part stream when uploading from Flex FileReference

Following the tutorial found on ASP.NET, implemented a Web API controller method for doing asynchronous file uploads that looks like this:
public Task<HttpResponseMessage> PostFormData()
{
// Check if the request contains multipart/form-data.
if (!Request.Content.IsMimeMultipartContent())
{
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
string root = HttpContext.Current.Server.MapPath("~/App_Data");
var provider = new MultipartFormDataStreamProvider(root);
// Read the form data and return an async task.
var task = Request.Content.ReadAsMultipartAsync(provider).
ContinueWith<HttpResponseMessage>(t =>
{
if (t.IsFaulted || t.IsCanceled)
{
Request.CreateErrorResponse(HttpStatusCode.InternalServerError, t.Exception);
}
return Request.CreateResponse(HttpStatusCode.OK);
});
return task;
}
Uploading a file via a standard multipart HTML form works perfectly. However, when another developer attempts to upload a file via multipart form constructed by Flex's FileReference class, an error is thrown:
Unexpected end of MIME multipart stream. MIME multipart message is not complete.
I have no idea if the problem lies in Web API or Flex. I've found some sort of related fixes that had no affect (Multipart form POST using ASP.Net Web API), and more recently this one ("MIME multipart stream. MIME multipart message is not complete" error on webapi upload). If the second link holds true, does anyone know if it's out in the current release of Web API available via Nuget? The discussion was in May, the most recent release from Nuget was August, so I assume this fix was deployed already, and is not the root cause of my issue.
I had the same problem with MVC4, but Will is correct, add a name to your input.....
<input type="file" id="fileInput" name="fileInput"/>
and all the magic is back up and working!
I had the same problem with flex. And below is the code that solved it. Basically I used a custom stream to append the newline that asp.net web api is expecting.
Stream reqStream = Request.Content.ReadAsStreamAsync().Result;
MemoryStream tempStream = new MemoryStream();
reqStream.CopyTo(tempStream);
tempStream.Seek(0, SeekOrigin.End);
StreamWriter writer = new StreamWriter(tempStream);
writer.WriteLine();
writer.Flush();
tempStream.Position = 0;
StreamContent streamContent = new StreamContent(tempStream);
foreach(var header in Request.Content.Headers)
{
streamContent.Headers.Add(header.Key, header.Value);
}
// Read the form data and return an async task.
await streamContent.ReadAsMultipartAsync(provider);
Hope this helps.
Reading through your existing research and following through to the codeplex issue reported it looks like someone else confirmed this issue to still exist in September.
They believe that MVC 4 fails to parse uploads without a terminating "\r\n".
The issue is really simple but extremely hard to fix. The problem is that Uploadify does > not add an "\r\n" at the end of the MultiPartForm message
http://aspnetwebstack.codeplex.com/discussions/354215
It may be worth checking that the Flex upload adds the "\r\n"
For those landing here googling:
Unexpected end of MIME multipart stream. MIME multipart message is not complete.
Reading the request stream more than once will also cause this exception. I struggled with it for hours until I found a source explaining that the request stream only could be read once.
In my case, I combined trying to read the request stream using a MultipartMemoryStreamProvider and at the same time letting ASP.NET do some magic for me by specifying parameters (coming from the request body) for my api method.
Make sure the virtual directory ("~/App_Data" directory as below example) where the image files are first uploaded are physically existance. When you publish the project, it may not be in the output files.
string root = HttpContext.Current.Server.MapPath("~/App_Data");
var provider = new MultipartFormDataStreamProvider(root);
I just removed my headers I was setting on my post method which ended up solving this issue.
The problem is this line:
string root = HttpContext.Current.Server.MapPath("~/App_Data");
It will only work in localhost, you can use HostingEnvironment.MapPath instead in any context where System.Web objects like HttpContext.Current are not available (e.g also from a static method).
var mappedPath = System.Web.Hosting.HostingEnvironment.MapPath("~/SomePath");
See also What is the difference between Server.MapPath and HostingEnvironment.MapPath?
Reference to this answer How to do a Server Map Path.

Resources