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

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

Related

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

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.

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

How to fetch mail by id with barbushin imap class

I'm currently working on the imap class by barbushin. It's the only php class over the internet I can find regardless to any encoding issue. Thanks to the coder.
I have a list of messages in a table. Each message sending a message id as GET (say $mid). When a link clicked, the page turned into a view page. It should open that message and display the relevant content right? But it is not. Every message has the same content (the 1st content). The code is designed for gmail but I use it for my client. And it's work.
This is a code:
require_once('../ImapMailbox.php');
define('EMAIL', 'my#domain.com');
define('PASSWORD', '*********');
define('ATTACHMENTS_DIR', dirname(__FILE__) . '/attachments');
$mailbox = new ImapMailbox('{imap.gmail.com:993/imap/ssl}INBOX', EMAIL, PASSWORD, ATTACHMENTS_DIR, 'utf-8');
$mails = array();
// Get some mail
$mailsIds = $mailbox->searchMailBox('ALL');
if(!$mailsIds) {
die('Mailbox is empty');
}
$mailId = reset($mailsIds);
$mail = $mailbox->getMail($mailId);
var_dump($mail);
var_dump($mail->getAttachments());
The original is here: https://github.com/barbushin/php-imap
Finally, I found my way home. According to the script there's a line says "mailId". Which is straight forward what is it about.
It was set to the first array by reset(). So the only thing I need to do is extract the message id from it ($mailId is an array of ids). So I simply add an array behind it.
$mailId=$mailsIds[$_GET[uid]];
While $_GET[uid] is a message id sent from a previous page.

Facebook doesn't accept custom Open Graph properties

I'm trying to use Facebook iOS SDK 3.5 for publishing an Open Graph action. My action is:
take a photo, and photo has an additional required string property named filter.
I am creating my graph object (all values are valid and working):
NSMutableDictionary<FBOpenGraphObject> *object =
[FBGraphObject openGraphObjectForPostWithType:#"tonerapp:photo"
title:#"photo"
image:imageData
url:nil
description:title];
Then I add my filter:
object[#"tonerapp:filter"] = filterName;
I try to post the object, and I can confirm that my filter property is there (enabled FBSetting logging behavior for URL requests to show request data):
Body (w/o attachments):
object: {"description":"","type":"tonerapp:photo",
"tonerapp:filter":"classic","data":{},
"fbsdk:create_object":true,
"image":{"url":"fbstaging:\/\/graph.facebook.com\/staging_resources\/MDExMDE1MjkzNzU1Njc3MDE0MjoxNTM4NzgwNjUy","user_generated":"true"},
"title":"photo"}
I can see my filter property there, but the response is this:
error = {
code = 100;
message = "(#100) Object Missing a Required Value:
Object at URL '' of type 'tonerapp:photo' is invalid because
a required property 'tonerapp:filter' of type 'string' was not provided.";
type = OAuthException;
};
Well, it IS there. I tried all possible combinations such as:
object[#"data"] = #{#"tonerapp:filter": filterName}; //wrapping into the data object
object[#"data"] = #{#"filter": filterName}; //wrapping into data and removing namespace
object[#"toner:filter"] = filterName; //app name instead of namespace name
object[#"filter"] = filterName; //no namespace name at all
[object setObject:filterName forKey:#"tonerapp:filter"]; //setobject notation
[object setValue:filterName forKey:#"tonerapp:filter"]; //setvalue notation
[object setObject:filterName forKey:#"filter"]; //setobject AND without namespace...
and possibly more. I've tried everything, but the API always fails with the same error. I can verify the rest of the object is correct, if I go to my app in Facebook and set filter as optional instead of required, it posts successfully. Is it a bug/insufficient documentation with the Graph API, or am I so blind that I can't see something obvious here?
Thanks,
Can.
just put them under "data"
object[#"data"][#"youcustomproperty"] = #"smth";
Be sure your filterName is URL encoded. I had the same kind of issue with the name of a movie which was also a custom action on the graph. Try just to post a manual value only a simple string and let us know.

IMAP - javax.mail. - Fetching Only Body Without Attachment

I am trying to develop an IMAP email client using the javax.mail API. I have been able to contact the servers, fetch emails, attachments and other operations without any problem.
However, we would not want to fetch the attachment until the user wants to view it explit in order to improve the performance. This would mean that we would need information which would indicate if the email has an attachment, if yes, then the filename(s) and the size(s)but would not send me the actual content of the email. However, I was not able to find a method in the API description which would return just the multi-part content.
Is there a way I could fetch just the body and the details of the attachment but not the actual attachment?
Thanks,
Aravind
The method getContent() of javax.Part returns
the content as a Java object. The type
of the returned object is of course
dependent on the content itself. For
example, the object returned for
"text/plain" content is usually a
String object. The object returned for
a "multipart" content is always a
Multipart subclass.
See http://download.oracle.com/javaee/6/api/javax/mail/Part.html#getContent%28%29
If a Message (which is a Part) contains attachments, the getContent method will return a Multipart object. In addition you can know the MIME type of the part with getContentType.
The information that is missing from the documentation is that this MultiPart object returned by getContent is just an empty representation of the Message's structure. The content of each Part of the Multipart will only be fetched from the server when you specifically ask for it. For example, to parse a multipart Message you would do:
if( p.isMimeType("multipart/*") ) {
Multipart mp = (Multipart)p.getContent();
// the content was not fetched from the server
// parse each Part
for (int i = 0; i < mp.getCount(); i++) {
Part inner_part = mp.getBodyPart(i)
if( inner_part.isMimeType("text/plain") ) {
String text = inner_part.getText();
// the content of this Part was fetched from the server
}
}
}
Something else to consider is that for optimal performance you should get the body structure information from the server in batch for the collection of messages you want to parse (see http://download.oracle.com/javaee/6/api/javax/mail/FetchProfile.Item.html#CONTENT_INFO). If not, each
Multipart mp = (Multipart)p.getContent();
will result in a request to the server to fetch the body structure. If the FetchProfile approach is used, the body structure for the collection of messages will be fetched with only one request. You can see the requests to the server in the log if you activate debug mode on the session:
session.setDebug(true);
This said, to get size and filenames of attachments just use Part.getSize() and Part.getFileName(), respectively.

Resources