Skip to content

Commit fcf377f

Browse files
authored
Merge pull request #71 from andreamorello93/feature/attachments-handling
2 parents 7bbcd1a + fbb197c commit fcf377f

File tree

3 files changed

+83
-6
lines changed

3 files changed

+83
-6
lines changed

NSF2SQL/Form1.Designer.cs

Lines changed: 51 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

NSF2SQL/Form1.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ private void bExportDocuments_Click(object sender, EventArgs ea)
326326
MessageBox.Show("Select a database.");
327327
return;
328328
}
329+
if (string.IsNullOrEmpty(txbAttachmentsFolder.Text))
330+
{
331+
MessageBox.Show("Select a folder for attachments.");
332+
return;
333+
}
329334
int total = 0;
330335
long startTicks = 0;
331336
long lastTicks = 0;
@@ -361,6 +366,23 @@ private void bExportDocuments_Click(object sender, EventArgs ea)
361366
startTicks = DateTime.Now.Ticks;
362367
for (int i = 0; i < total; i++)
363368
{
369+
object[] items = (object[])doc.Items;
370+
371+
foreach (NotesItem nItem in items)
372+
{
373+
if (nItem.Name == "$FILE")
374+
{
375+
NotesItem file = doc.GetFirstItem("$File");
376+
377+
string fileName = ((object[])nItem.Values)[0].ToString();
378+
379+
NotesEmbeddedObject attachfile = doc.GetAttachment(fileName);
380+
381+
if (attachfile != null)
382+
attachfile.ExtractFile($@"{txbAttachmentsFolder.Text}\{fileName}");
383+
}
384+
}
385+
364386
//check if cancelled
365387
if (pDialog.IsCancelled)
366388
{
@@ -830,5 +852,11 @@ private NotesSession initSession(string password)
830852
nSession.Initialize(password);
831853
return nSession;
832854
}
855+
856+
private void btnBrowseAttachmentsFolder_Click(object sender, EventArgs e)
857+
{
858+
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
859+
txbAttachmentsFolder.Text = folderBrowserDialog1.SelectedPath;
860+
}
833861
}
834862
}

NSF2SQL/Form1.resx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
129129
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
130130
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAa
131-
CQAAAk1TRnQBSQFMAgEBAgEAATABAAEwAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
131+
CQAAAk1TRnQBSQFMAgEBAgEAATgBAAE4AQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
132132
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
133133
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
134134
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
@@ -172,6 +172,9 @@
172172
<metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
173173
<value>267, 17</value>
174174
</metadata>
175+
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
176+
<value>403, 17</value>
177+
</metadata>
175178
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
176179
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
177180
<value>

0 commit comments

Comments
 (0)