Mail-in db with attachments not appearing in the Body field - lotus-notes

I have a mail-in database application and I am finding that occasionally an email is received with an attachment that is not part of the Body field and therefor not able to be "seen" by rtItem.EmbeddedObjects.
How do I identify that there is an attachment if it is not in the Body and once I do that how do I get a handle on it?
I need to determine the type of attachment (PDF, JPG, DOC, XLS, etc.), detach it and then process it based on the extension.
Here is the various If statements that do all the checking of the Body (RTF) field and the associated EmbeddedObjects. This does not catch an attachment that is "outside" of the Body.
Set rtItem = mailDoc.Getfirstitem("Body")
If ( rtItem.Type = RICHTEXT ) Then
If Not (IsEmpty(rtItem.EmbeddedObjects)) Then
ForAll o In rtItem.EmbeddedObjects
If (o.Type = EMBED_ATTACHMENT) Then
noAttachment = True
Else
noAttachment = True
End If
End ForAll
Else
noAttachment = True
End if
Else
noRTF = True
End If
I also have a document with nothing in the Body but $File contains the attachment name. How do you find that?

Youll need to get at those attachments using the EmbeddedObjects property of the NotesDocument. The union of that property plus all the EmbeddedObjects properties of all rich text items gives you access to all the attachments. Note that usually you only need to worry about the Body rich text item.

FYI we've hit a similar problem when the mail server was running out of disk space, or if a virus scanner blocked access to the attachment

Related

How to get HTML content out of Richtext field of Notesdocument

enter image description hereHi In My Xpages application, I would like to take reference of HTML stored in NotesDocument richtext field( Cofiguration document in Notes Client ), so in Xpages data source I mentioned configDoc as source as Notes Domino Document and in Default Action I set it to " Open Document" and in Document id " I set Computed value as below"
var vw:NotesView = database.getView("vwConfig")
var doc:NotesDocument = vw.getFirstDocument()
var uniid:String = doc.getUniversalID();
return uniid
In one of the place I placed on computedField property, I mentioned ssjs code as
return configDoc.getValue("RTFIeldasHTML").getHTML();
this works if I open document but does not work if I open existing document and it gives me an error:
Error while executing JavaScript computed expression
docConfig.getValue()' is null
Most likely cause is docConfig doesn't have ignoreRequestParams="true". That means it's opening the document whose ID is in the URL and ignore anything you put in the documentId property. Set that and it will work correctly.

Aegis Implicit Mail AIM AlternateView in MimeMailMessage

I am using AIM Aegis Implicit Mail to send Implicit ssl mails.
When using subject and body in a mail message all is fine, however when I use alternate views my mai lhas an empty body. This alternate view setup works with mailmessage and has html and text body depending on the reciving client but I must use MimeMailMessage which looks ok in the debug code but is empty when recivied in the mailbox.
Here's the code:
string plainTextBody = "Welkom.";
AlternateView plainTextView =
AlternateView.CreateAlternateViewFromString(
plainTextBody, null, MediaTypeNames.Text.Plain);
plainTextView.ContentType = new System.Net.Mime.ContentType("text/plain");
mail.AlternateViews.Add(plainTextView);
string htmlBody = #"<html><body><img src=""cid:logo""><br /> Welkom </body></html>";
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);
htmlView.ContentType = new System.Net.Mime.ContentType("text/html");
string imageSource = Path.Combine(HttpRuntime.AppDomainAppPath, #"Content\Images\Logob.png");
LinkedResource PictureRes = new LinkedResource(imageSource, MediaTypeNames.Image.Jpeg);
PictureRes.ContentId = "logo";
htmlView.LinkedResources.Add(PictureRes);
mail.AlternateViews.Add(htmlView);
Aim is not providing AlternativeView, however you can use inline attachments to put your images and directly set HTML code in your message body. try to download the sample code and have a look on how inline attachments are working

Setting a document field with replaceItemValue from a rich text control?

How do you set a richText value with replaceItemValue from a rich tect control?
I found this bit of code here:
http://www.bleedyellow.com/blogs/martin/entry/save_a_richtext_field_from_a_xpage_to_a_document?lang=en_us
var doc = configuratieformulieren.getDocumentByKey("ConfiguratieIVNL", true);
if(doc == null){
return;
}else{
var titel = getComponent("inputTextIBPTitelIVNL").getValue();
doc.replaceItemValue("IBPTitel",titel);
var inhoud = getComponent("inputRichTextIBPInhoudIVNL").getValue();
if (inhoud != null){
var contentType = doc.getMIMEEntity("IBPInhoud").getContentType();
var encoding = doc.getMIMEEntity("IBPInhoud").getEncoding();
var str = session.createStream();
inhoud.toString();
str.writeText(inhoud.toString());
doc.getMIMEEntity("IBPInhoud").setContentFromText(str, contentType, encoding);
}
doc.save(true, true);
}
sessionScope.put("FormulierIVNLInfoBeschPG","Lezen");
Is it correct? It looks like this code depends on the fact that the field already exists. How id this handled if the field does not exist? Is there and easier way to set a field value to the contents of a rich text control?
Let data sources do the heavy lifting. For a long and boring (but thorough) explanation of why, read this article. But here's the quick version:
Don't use:
getComponent("someID").getValue()
Instead, use:
someDataSource.getValue("someFieldName")
This is always a more efficient way to access data: instead of having to spider through the component tree to locate a match, it goes straight to the data source, which the component would have to ask anyway if you asked it what its value is.
Similarly, don't use:
someDataSource.replaceItemValue("someFieldName", someValue)
Instead, use:
someDataSource.setValue("someFieldName", someValue)
The latter is much more flexible on input type. The data source already contains all the logic for determining what to do based on whether the value is text, date, number, rich text, file upload, etc. No need to duplicate any of that logic in your own code.
So if the goal is to update a separate document based on data in the current document, just define a separate document data source that points to the document you want to update. Then it's literally this simple:
configData.setValue("RichTextData", currentDocument.getValue("RichTextData"));
configData.save();
With the above code, if the field you specify on the current document is rich text, then the item it creates on the other document will be rich text. If it's any other type on the current document, it will be the same type on the other document. With getValue() and setValue(), you don't have to pay attention to the data type... the data source handles all of that for you.
For bonus points, scope configData to applicationScope so that any updates to it are immediately cached for all users... or sessionScope if the document you're updating is user-specific.
I was able to solve my orginal issue. To expand on my issue I was having problems with using a dialog box to create Form / Document B from Form / Document A using a dialog box on Form A. What was happening was any changes to Form B would be saved to Document A's datasource.
I found the ingoreRequestParams on Form B's datasource, set it and that solved my problem with Form B writing to Form A document.

Search Mailbox of Mail.app with Applescript

I want to be able to search a mailbox in apple's mail.app for a phase or word, then somehow return or copy all of the email addresses from which the emails which have successfully returned from the result of the search have been sent from.. if you get what i mean
I thought that the only way to do this is probably applescript but if anyone else knows any other way please tell me :)
Mail.app doesn't allow searches directly via Applescript but this will do the trick, though it is a bit slow because it has to iterate through each message:
global searchTerm
property emailList : {}
set searchTerm to "aSearchTerm"
tell application "Mail"
set theInbox to inbox
set firstMessage to 1
set lastMessage to (get count of messages in theInbox)
repeat with thisMessage from firstMessage to lastMessage
set currentMessage to message thisMessage of theInbox
set messageContent to content of currentMessage
if messageContent contains searchTerm then
set end of emailList to sender of currentMessage
end if
end repeat
end tell
return emailList
you could also invoke a real search in the interface and then collect the items
[Applications launch:#"Mail"];
[Keyboard command_alt_press:'f'];
[Keyboard paste:term];
+(void) command_alt_press:(char)c{
[self runScript:[NSString stringWithFormat:#"tell application \"System Events\" to keystroke \"%c\" using command option down",c]];
}
you seem competent enough to complete the rest of the code.

SharePoint : Guessing the attachment path before updating a list item

I have some code that inserts a list item into a list...
I then have this code
SPFolder folder = web.Folders["Lists"].SubFolders[list.RootFolder.Name].SubFolders["Attachments"].SubFolders[item.ID.ToString()];
foreach (SPFile file in folder.Files)
{
string attachmentName = this.downloadedMessageID + ".xml";
if (file.Name == attachmentName)
{
SPFieldUrlValue value = new SPFieldUrlValue();
value.Description = this.downloadedMessageID + ".xml";
value.Url = this.SiteAddress + file.Url;
item["ZFO"] = value;
}
}
this is fine except for one problem... before this code actually works... I need to call the item.update() method to save the item to SharePoint...
But as you can see there is more work to do ... after item.update is called...
So this means... I have
work
item.update();
more work
item.update();
The problem I am having is I really want just
work
item.update();
So that in any event of failure the whole thing will fail at once or pass at once.... (almost like a SQL transaction).
So whats preventing me from doing this is - I need to set a hyperlink to one of the fields in the list item, this will be to an attachment in the list attachments collection.
Is there any way I can predict this address without having saved the list item to MOSS?
An attachment path depends on the item ID, and I don't believe your item will have an ID until you save it. Have you considered storing the attachments in a document library instead, linked by the field you're trying to set?
Transactional operation isn't exactly SharePoint's strong suit.

Resources