Lotus notes Document appears both in Inbox and SentItem - lotus-notes

I have created a CPP COM dll to read a EML File and add it to Lotus notes NSF file. Using MIMEContent to create the mails but the problem is when i am adding the document to folder view $Inbox same mail is copied $Sent Item Folder. Below is the code
newdoc.Save();
Folder.FolderAddDocument(newdoc);
// Color the background
Folder.SetBackgroundColor(LNCOLOR_LIGHT_GRAY);
// Change the heading display
Folder.SetHeadingDisplay(LNVFHEADINGDISPLAY_BEVELED);
Folder.Save();
//cout<<"ReadViews4"<<endl;
Folder.Close();
//cout<<"ReadViews5"<<endl;
newdoc.Close();
Thanks and Regards,
Haseena

This is the selection formula for the Sent view of the 8.5.x mail template:
SELECT DeliveredDate = "" & PostedDate != "" & !(#IsMember("S";
ExcludeFromView))
If the imported mail document should appear as a incoming mail, it must have a DeliveredDate field with a date (which then means that it will not appear in the Sent view).
I can not see how you set the properties of the mail document, since your code example only contains newdoc.Save() and newdoc.Close().
So have a look at the properties of your imported mail, and have a look at the CPP code that sets the properties of the mail document.

Like others said:
Create the field "DilveredDate". Replace its value with e.g. Today.
DateTime timenow = session.createDateTime("Today");
timenow.setNow();
newdoc.replaceItemValue("DeliveredDate", timeNow);
And your document will not show up in the sendTo-View.

Related

How to open website link by clicking on lotus notes mail subject?

is there any way to click on the mail subject on lotus notes and direct to the link?
Example :
Who Subject Date Size
kit `food list` 11/09 2k
Expected outcome :
when i click on the 'food list', it will redirect to the website link.
I think it is possible. Either you can add some more fields/headers with the mail or have a special subject tag included.
Then you need to change the queryopen event in the mailbox to check for the field/subject tag, parse the mailbody, open the link end set continue = false to prevent the mail from opening.
A notes only solution would be to send a special form within the email...

Lotus Notes - get mail database of current user

Is there a way in Lotus Notes (using either #Formula or LotusScript) to get the mail file path of the current user?
Dim maildb As New NotesDatabase("", "")
Call maildb.OpenMail
gives you the mail database of current user.
maildb.FilePath returns the file path.
#MailDbName is the formula counterpart to the answer from Knut. It returns a text list with two elements: Server and path.

Lotus Script - Send email does not attach form

I am trying to send email from Lotus Script. But the email doesn't seem to have the FORM ( named Email Form , referred below in the code ) attached to it, when received in the inbox.
When I check the Document property in the email, it says the form is "Memo" and the FROM, TO addresses are Blank.
I have defined the FROM, TO,SUBJECT,BODY fields in the Email Form in a specific format .
But all these field values are populated correctly in the form. Issue happens only after send .
The Same code works fine in some other Lotus Notes, when the email is triggered by another person, having a different Notes ID configured in that system .
Not sure if this is code issue, or Lotus Notes configuration issue .
Any help to solve this would be greatly appreciated . The for has the property " Store Form in Doc" set and even ComputeWithForm returns success .
Could this be a problem with my Lotus notes settings/configuration? .Same code sends email in correct format in some other system configured wit their Notes ID
Here is a sample code on the EMAIL Action button
Sub Click(Source As Button)
Set email = db.CreateDocument
Call email.ReplaceItemValue("Form", "Email Form")
Call email.ReplaceItemValue("Subject", " My TestEmail")
Call email.ReplaceItemValue("From", nom.Canonical)
Call email.ReplaceItemValue("SendTo", nom.Canonical)
Call email.ReplaceItemValue("Body", " Hello, my test email ")
Call email.Send(True,nom.Common)
End Sub
It seems you mixed syntax here, you both set SendTo and specify nom.common, only one should be done. As in the help you should use:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set doc = New NotesDocument( db )
doc.Form = "Email Form"
doc.SendTo = "Elissa Minty"
doc.Subject = "Here's the document you wanted"
Call doc.Send( true ) 'true here means you the form is stored and sent along with the document.
Now, check that you "Allow use of stored forms in this database." in your DB, could it be that this code exists in differents DBs and one doesn't have "Email Form" ? BTW check is it really "Email Form" and not "Email" ?
You may need also to check the local configuration on the client. To do this refer to Help.
Its not that complicated to send mails usually, with docs from a Mail Enabled database. But now you have added a more complicated solution, than necessary, you may want to review your solution, to save yourself of future problems.
You won't even need to LotusScript this, provided the Mail fields (SendTo as minimum) is there on the document.
See here how:
Designer 8.5.3 Help - Setting up automatic mailing

Can't migrate RichText to RichText in XPages

I have an old Notes Client application. On the form are two RichText fields that hold attachments. JPG's, PDF's, whatever. The document also contains a unique key and other meta-data.
What I want to do is migrate from having multiple attachments on a document to a new document for each attachment. I've never done much with embedded objects and even less with MIME.
I'm currently working in XPages Java but could go to LotusScript if need be.
I was working with this snippet:
List<EmbeddedObject> docPicture = this.getFileAttachments(doc, "picture");
List<EmbeddedObject> docPDF = this.getFileAttachments(doc, "pdf");
for (EmbeddedObject eoPic : docPicture) {
picCount++;
Document newDoc = currentDatabase.createDocument();
newDoc.replaceItemValue("form", "fm_file");
newDoc.replaceItemValue("uploadToken", doc.getItemValueString("barCodeHuman"));
newDoc.replaceItemValue("fileName", eoPic.getName());
newDoc.replaceItemValue("size", eoPic.getFileSize());
fileName = eoPic.getName();
fileType = fileName.substring(fileName.length() - 3);
newDoc.replaceItemValue("type", this.getMIMEType(fileType));
// Extract Attachment and Add To Attachment Document
InputStream attachInputStream = eoPic.getInputStream();
Stream attachStream = session.createStream();
attachStream.setContents(attachInputStream);
MIMEEntity attachField = newDoc.createMIMEEntity("attachment");
MIMEHeader attachHeader = attachField.createHeader("content-disposition");
attachHeader.setHeaderVal("attachment;filename=\"" + eoPic.getName() + "\"");
attachField.setContentFromBytes(attachStream, this.getMIMEType(fileType), MIMEEntity.ENC_IDENTITY_BINARY);
Note I'm using the OpenNTF API but could go back to the lotus objects if need be.
Anyway - this almost worked. I got my documents - 1 per attachment. But when going into the field "attachment" in the document propertied it's not a RichTextField it's a MIME something. that's causing me probably with the next phase of my project. The RichTextDocuments work fine but not the MIME ones.
this is a 1 time migration need so any thoughts on how I can end up with RichTextFields would be appreciated. Thanks!!
try to not involve mime entities at all.
as Oliver said, check your target richText field on the form does not have the 'store contents as mime' checked.
you could even use a richText lite field and restrict it to attachments.
I think you might be using the MIMEEntity method setContentsFromStream because you want to directly move the attachment from doc to doc?
if you want to move using just RichText embedded objects (no mime entity involvement) you need to extract the embeddedObject using .extractFile to the file system first.
Then using the RichTextItem that you create on the new doc (instead of create mime entity) you can use rti.embedObject to attach the file you extracted. (probably best to delete the temporary extract file after successful migration), see the designer help for an example of the parameters required for embedding attachments.
when extracting the file to file system you could extract it to the JVM's temporary directory, the file on the file system needs to have the same file name that you want it to have when attached to the new document.
for this reason you can't really use File.createTemporaryFile() because your temp file name will have random characters in it. instead you
you can get the temp directory with
System.getProperty("java.io.tmpdir")`
and the use that in your extract filepath.
another thing to check before starting processing, is the current notesSession's isConvertMIME setting, if to source field is mime, session.isConvertMIME == true will convert the field to richText when loading the doc. I think in xpages it is false by default, though I don't think it will affect you because I think your source attachments are already richText but for someone reading this and using mime source field it would be important to note. also if you change this using setConvertMIME, be sure to change it back to what it was when you finish your processing.

Changing Sent By in Mail Document in Lotus Notes

I would like to also change the field "sent by" (displaying when there is a mailDoc.Principal) in the mail being sent by a triggered agent created in lotus script. Is it possible to change it I already tried the following codes
mailDoc.SentBy = strFrom
mailDoc.tmpDisplaySentBy = strFrom
mailDoc.FROM = strFrom
mailDoc.SendFrom = strFrom
Still I couldn't change that part.. Is it possible or is there some limitation?.. Thanks
You can't change it. The server puts always the current username into field Principal/From.
But there is a workaround: instead of sending the mail save the mail document into mail.box on server with a Principal/From field content of your choice. This way server won't change the field anymore.
Here is an example from Karl-Henry Martinsson how to do it.

Resources