C# Lotus Notes - multiple .nsf files - c#

I send mails from C# code via Lotus Notes and it works really fine - with Win7 and WinXP.
But some users of my program have multiple .nsf files in the directory, like 'user1.nsf' and 'old-user1.nsf'.
How can I retieve which of these files is the active database I have to use?

If your code runs on users machine then you have "MailFile" and "MailServer" variables in notes.ini file.
Where is this directory located?

You don't need to care which mail database is active if you are sending emails. Just create a new NotesDocument object in memory, fill out the appropriate properties (subject, Body, etc), and then call the Send method on that object. Notes takes care of the rest.
If you need to get the mail database information for a user for another reason, there is a GetUserInfo method for that on the NotesRegistration class
Or in formulas, there is the #MailDbName formula.

If you're just using the user's mail file, in LotusScript you can just use
Call notesDatabase.OpenMail
That way, you never need to bother with where the mail file is - you get the handle to it seemlessly.

Related

Outlook API GetItemFromID() fails with error "Could not open the item.Try again." when using multiple outlook accounts

I am using two outlook accounts from the same exchange server (i.e. same domain). We have an outlook add-in which we use to archive some emails from outlook to an external web application. While composing a new mail, it's possible to attach some files from external application to the mail being composed using the add-in.
Now things work perfectly when I have a single account on outlook. But after configuring another account and trying to do the same from secondary account, outlook gives error:
Outlook Initiator exception:
System.Runtime.InteropServices.COMException (0x80040107): Could not
open the item. Try again. at
Microsoft.Office.Interop.Outlook.NameSpaceClass.GetItemFromID(String
EntryIDItem, Object EntryIDStore)
I tried to dig into the code and found that the call to GetItemFromID() gives the exception shown above.
object item = ns.GetItemFromID(objectID, storeId);
The first parameter objectID (which is EntryIDItem) is different for different accounts but second parameter storeId is same.
I also tried to see the body of the method GetItemFromID() using disassembler but the method is defined as an extern method that means it's defined outside of the current assembly as un-managed code.
Tried to search for anything similar to that on stackoverflow but no luck. Can anybody please help me on this?
Try to leave only the first parameter. The EntryIDStore parameter is optional. See NameSpace.GetItemFromID for more information.
Note, the Entry ID changes when an item is moved into another store, for example, from your Inbox to a Microsoft Exchange Server public folder, or from one Personal Folders (.pst) file to another .pst file. Solutions should not depend on the EntryID property to be unique unless items will not be moved.

find New Emails that comes into exchange email server

Right now I have a Microsoft Exchange mail server and I want to extract information from that exchange server directly to my own SQL database so I can analyze them.
Now the problem is right now the way I come up with extract information from this exchange database is to check every user then check every folder they have then check all the content under each folder and if I see any modified or new emails I copy,update that into my own database.
this method does work for small amount of data however if I try to copy large amount of data with this :eg 1000 users the process will take minutes if not longer because I am constantly doing loops over loops to check every single email one by one for difference. I want to have a way to only loop through a folder if it is modified.
I looked at the documentation of Microsoft on Exchange folders I see the function called IsDirty. The description says it returns true or false based on whether the object has been modified. Now I am confused on what is it comparing the object to. Does it compare the object with whether it was modified upon creation? or a specific date I tried to look for information on this and I can't find any. Also is there any other faster way of detecting new emails/modified emails in the exchange without looping through all the folders and all the emails thanks.

how to read mail from Google mail and mark as save and save mail in local folder with C# .NET

I am trying to build a winform app to
read mails from google app
save mail and attachment to local folder
mark mail as read
Save the email body and attachments to a SQL-Server database
The latter is ok but I'm really having trouble with the first 3.
I've look everywhere and people are telling me how to send mail on a winform app but not how to read, mark and save content and attachment.
CodeProject is probably the next best resource online after SO (IMHO.) Here are some well-reviewed sample projects that will get you a long way:
http://www.codeproject.com/Articles/14304/POP3-Email-Client-NET-2-0
http://www.codeproject.com/Articles/6062/A-POP3-Client-in-C-NET
http://www.codeproject.com/Articles/188349/Read-Gmail-Inbox-Message-in-ASP-NET
http://www.codeproject.com/Articles/34495/Building-your-own-Mail-Client-using-C
http://www.codeproject.com/Articles/15611/POP3-Email-Client-with-full-MIME-Support-NET-2-0

Exchange WS 'The specified object was not found in the store.' error

We're using Exchange 2007 WS to process mail folders and are hitting various problems if we try and forward a message we've already received. Our process is:
Windows Service monitors mailbox folder, on finding a new mail we process the information and move the item to a 'Processed folder' and store the Exchange Message Id.
Users may opt to forward the mail externally. We use the Exchange API to find the item using the Message Id we stored earlier, and then again use the API to forward.
Except finding the mail again is proving rather flaky. We regularly get the following error:
The specified object was not found in the store.
Is there a better/more reliable way we can achieve the same? The documentation for Exchange WS is rather sparse.
This is a bug in microsoft exchange manage API. here is a link for more information
http://maheshde.blogspot.com/2010/09/exchange-web-service-specified-object.html
Are you saving the Message ID of the newly found message or the message once it has been moved to the 'Processed' folder? The id will change when it moves to a new folder.
The method recommended in the book Inside Microsoft Exchange Server 2007 Web Services is to grab the PR_SEARCH_KEY (0x300B, Binary) of the newly discovered item, then move it to the 'Processed' folder. You can then search for it in the new folder based on the PR_SEARCH_KEY and get it's new Message id to forward it.
I have come to the conclusion that this happens to me is because while my app is processing the emails, someone else is fiddling with an email at the same time.
So to cure the problem, I put it the code in a try catch and see if the exception is == the that object not found in store, if so I just skip it and move on to the next item. So for has no issues.
I wrote a program that reads the emails in inbox downloads attachments to the specified folder, wrote the email info and the saved path to the database, and finally deletes the email. I run this program as a windows service. After all tests are finished I run this program to the main server and run it. Program runs successfully but sometimes I got this error. I checked everything and finally I found that I forgot to stop service on my computer. 2 programs that runs on my computer and on real server checking the same mailbox at the same time. If you get this error make sure that only one program can process at the same mailbox.

IIS Permissions for Saving Word Documents

Our ASP.NET/C# lets users edit and manage Word (OpenXML) documents that are hosted on a server. I am using client-side VBScript functions to handle some of the editing functions including saving the document to a folder on the server. For the save functionality, I am using the following function call :
Document.SaveAs "http://server/savefolder/savefile.docx"
I have given "Full Control" permissions on savefolder to both the NETWORK SERVICE and the IUSR_MACHINE users. Yet the above call fails. The error number returned is 5096. The error message is some gibberish that doesn't make any sense.
The server is Windows 2003 and the IIS version is 6.0. I have installed the OpenXML SDK 2.0 CTP on the server.
I can successfully read and print documents.
Does anyone tell me what I am doing wrong? or what additional settings need to be in place?
BTW, the error message ("gibberish" from my post) is:
"EOALPHABETICARABICARABICABJADARABICALPHABAHTTEXTCAPSCARDTEXTCHARFORMATCHI"
No, I am not making this up!
In my case, that error 5096 with description "EOALPHABETICARABICARABICABJADARABICALPHABAHTTEXTCAPSCARDTEXTCHARFORMATCHI"
occurred when using VBA code in Access to drive a Word mail-merge. The cause was trying to save a document with the same name (including path) as an open document.
Error line:
objApp.ActiveDocument.SaveAs saveAsName
where objApp is the object variable representing the Word application and saveAsName is the string variable storing the name I am trying to save the file as e.g. "C:\temp\testdoc.docx".
IF a file with the same name exists but is not open, the above code overwrites it silently.
Turns out WebDAV is not turned on by default in IIS 6.0. Once I turned it on, I was able to save the documents just fine.
Thanks for all your answers!
Just a guess... if the vbscript is running on the client, the code is probably running under the user's account, not under the server's IIS account. So unless you give write access to that user, vbscript probably won't work for this.
Since you're using ASP.NET, you could try writing a web service that takes in Word document data and saves it to the server for you.
I'd try running Fiddler on the client while trying to save the document to get a sense of what's really going on. I wonder if maybe it's trying to do an HTTP PUT (as opposed to a POST).
Have you given write access to the folder in IIS manager?
Is the save folder you're using outside of the websites root directory, i.e. 'hidden' from the internet?
Just to add to SI's information...
I also get this I get the 5096 - EOALPHABETICARABICARABICABJADARABICALPHABAHTTEXTCAPSCARDTEXTCHARFORMATCHI error when my code tries to save a MS Word document with the same name and to the same location as a Word document that is already open in another instance of Word.
Although not entirely relevant to this thread, I hope it may help someone else who stumbles upon this thread!
Regards,
Duane,
this question is old but still active ?
You save the file with a http://... url, i think you should save it with a file URL as
Document.SaveAs "\\server\savefolder\savefile.docx"
Grtz

Categories

Resources