we use VBScript for changing EXIF data of .msg files.
We access msg files using
Set Element = Session.GetMessageFromMsgFile(msgFilePath)
It works fine, exept that the msg file gets locked, so that writing EXIF data to the file fails.
How can I release the msg file (Element), as Marshal.ReleaseComObject() doesn't work within VBScript? Setting Element=Nothing doesn't work either.
Thanks!
Chris
In VB script, just setting the RDOMail object to Nothing will do the job:
set Element = Nothing
Related
We are having an issue with a .CSV file, it is being locked by another process on any shared folder location.
Before mid December this worked with no problem, but since then our guys keep getting this same error on the files. "The process cannot access the file "Filename.." because it is being used by another process" Once they are written into once and it appears that the shared file resource is keeping this file open, we have checked and we can see the close request coming through on the file server but it doesn't appear to be successfully closing said file.
Here is the code snippet which I have chopped down to get rid of the unnecessary information for our VB.Net application which creates and writes to the file in case it relates to it but it appears to be something with file sharing on Windows.
Try
Dim nowPathString As String = Now().ToString("yyyyMMdd-hhmmss")
Dim nowString As String = Now().ToString() '
Dim csvFilePath As String = $\\webserver\ExcelTest\Test-{nowPathString}.csv 'Path to create or existing file
Dim outFile As IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(csvFilePath, False)
outFile.WriteLine("Warehouse, StockItemCode, AllocationQuantity, Reference, SecondReference, ActivityDate")
outFile.WriteLine($"Main, SHE060, 1, 123456, 123456-1, {nowString}")
outFile.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Any help or suggestions on this is greatly appreciated!
We thought this issue may be server related so we created a shared folder on our local C drive and the same issue occurred but if you save the file onto your local C drive normally it works.
The way to get around this being stored on our server is to go in and manually close the file down by using console root and the "Shared Folders" snap-in.
I am getting the currently selected mailItem from the explorer and saving it to the local file system. The file is then being uploaded to a server. My problem is sometimes the server (which I have no control over) returns that the file format is invalid.
I save the mailItem with the following code:
oMailItem.SaveAs("C:\path\savedEmail.msg")
This creates a file which is 174kb in size. If I add the OlSaveAsType of olMSG then I get the same file size.
If I save the exact same email with the Outlook UI then the chosen/suggested Message format is Unicode. This produces a file of about 251kb ie. much bigger. If I save it with the above code and olMSGUnicode then I also get the same file size.
I am therefore assuming that leaving out the OlSaveAsType option saves the mailItem as an olMSG.
I am currently also assuming that this may be causing some issues with the upload to the server.
What property of a mailItem tells me which OlSaveAsType to use? Can I safely use olMSGUnicode for all saves?
Yes, you can safely use olMSGUnicode format on all modern versions of Outlook.
But the real problem is why the server (?!) returns an error that the format is invalid? Was it corrupted? Can you successfully open the same file you sent to the server? You need to figure out why that error is returned.
I have a C# Outlook add-in that is using the Redemption library.
This add-in, among other things, copy the selected mail to a share somewhere on the network.
It usually works pretty well but sometimes, the .msg file on the share seems to be corrupted. It cannot be read by the service that tries to process it. Double clicking on it shows this message: "Cannot read the item".
Sometimes, I can see an error message:
SaveEmail - System.Runtime.InteropServices.COMException (0x8007000):
Error in StgCreateDocFile: 0x8007000 at
Redemption.IRDOMail.SaveAs(String Path, Object Type) at
XYZNameSpace.Email.SaveEmail(...)
Here the code that save the mail to the share:
// Save the mail in a temp local file first
mailItem.SaveAs(temppath, Outlook.OlSaveAsType.olMSG);
(... some processing ...)
// Reload the mail
RDOMail rm = rdoSession.GetMessageFromMsgFile(temppath);
// Save it again on a share
rm.SaveAs(filePathName, Outlook.OlSaveAsType.olMSG);
Note 1 : I don't know why the mail is first saved locally!
Note 2 : It is using an older version of Redemption (2015).
Note 3 : The size of the message doesn't seem important. However, they are
usually between 2 and 15 MB.
Many thanks in advance.
IStorage API does not really like remote drives - there is no way for the storage sharing features to work.
Opening and saving the message the second time really does not make much sense - why not simply copy the MSG file using the file system API?
Im attempting to parse .msg files from outlook to get the MIME content in order to save the file as an eml. I'm using Exchange Web Services to save emls as they come through a journaled inbox on the exchange server, but some emails need to be saved after the fact through an outlook add in, though getting them into an eml/MIME format seems more difficult.
The example on the mimekit github page shows it can parse a msg file, though when I attempt it, a System.FormatException is thrown. Does mimekit support msg parsing?
This is what I am doing right now:
var stream = File.OpenRead(#"C:\example.msg");
var parser = new MimeParser(stream);
var msg = parser.ParseMessage();
Any amount of insight would be incredibly helpful.
MSG format is not MIME - try to open it in Notepad. It is an OLE storage file.
To open IStorage file, use StgOpenStorage.
See Difference between a .msg file and a .eml file
I'm trying to upload a file to SkyDrive using Live SDK. It works well except overwriting existing files. Whenever I try to overwrite an existing file I get the error message "The resource file_name already exists.", although I use the Overwrite option:
_liveClient.UploadAsync(
FolderId,
Filename,
MemoryStream,
OverwriteOption.Overwrite);
Is there anything else I need to set?
I could try handling the error by deleting the file and uploading again but that's obviously not the cleanest way to do that.
Microsoft admitted here that it's a bug that they are aware of . It will be fixed in the next release.
Also, as per answer in that link, the overloaded method works fine:
_liveClient.UploadAsync(
FolderId,
Filename,
MemoryStream,
OverwriteOption.Overwrite,
null);
When your upload a file, and a file with the same name already exists in the same location in SkyDrive, the default behavior is for SkyDrive to overwrite the existing file. You are not required to specify OverwriteOption.
From my point of view, there is a problem else where. Try to use another folder and show a little more code.