Skip to content

Commit 390b359

Browse files
authored
Merge pull request #92 from lesh-andrew/optional_attachments
2 parents a6016ef + 94721c4 commit 390b359

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

NSF2SQL/Form1.cs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,16 @@ private void bExportDocuments_Click(object sender, EventArgs ea)
326326
MessageBox.Show("Select a database.");
327327
return;
328328
}
329-
if (string.IsNullOrEmpty(txbAttachmentsFolder.Text))
329+
330+
string attachmentsFolder = txbAttachmentsFolder.Text;
331+
332+
if (string.IsNullOrEmpty(attachmentsFolder))
330333
{
331-
MessageBox.Show("Select a folder for attachments.");
332-
return;
334+
var result = MessageBox.Show("You did not select a destination for attachments. The export will proceed without pulling any of those fields. Cancel to select a folder.", "Notice", buttons: MessageBoxButtons.OKCancel);
335+
336+
if (result == DialogResult.Cancel) return;
333337
}
338+
334339
int total = 0;
335340
long startTicks = 0;
336341
long lastTicks = 0;
@@ -367,19 +372,21 @@ private void bExportDocuments_Click(object sender, EventArgs ea)
367372
for (int i = 0; i < total; i++)
368373
{
369374
object[] items = (object[])doc.Items;
370-
371-
foreach (NotesItem nItem in items)
375+
if (!string.IsNullOrWhiteSpace(attachmentsFolder))
372376
{
373-
if (nItem.Name == "$FILE")
377+
foreach (NotesItem nItem in items)
374378
{
375-
NotesItem file = doc.GetFirstItem("$File");
379+
if (nItem.Name == "$FILE")
380+
{
381+
NotesItem file = doc.GetFirstItem("$File");
376382

377-
string fileName = ((object[])nItem.Values)[0].ToString();
383+
string fileName = ((object[])nItem.Values)[0].ToString();
378384

379-
NotesEmbeddedObject attachfile = doc.GetAttachment(fileName);
385+
NotesEmbeddedObject attachfile = doc.GetAttachment(fileName);
380386

381-
if (attachfile != null)
382-
attachfile.ExtractFile($@"{txbAttachmentsFolder.Text}\{fileName}");
387+
if (attachfile != null)
388+
attachfile.ExtractFile($@"{attachmentsFolder}\{fileName}");
389+
}
383390
}
384391
}
385392

@@ -393,7 +400,7 @@ private void bExportDocuments_Click(object sender, EventArgs ea)
393400
{
394401
//get form
395402
string form = ((string[])doc.GetItemValue("Form"))[0];
396-
403+
397404
if (!tables.ContainsKey(form))
398405
{
399406
tables.Add(form, new Table(form));
@@ -856,7 +863,7 @@ private NotesSession initSession(string password)
856863
private void btnBrowseAttachmentsFolder_Click(object sender, EventArgs e)
857864
{
858865
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
859-
txbAttachmentsFolder.Text = folderBrowserDialog1.SelectedPath;
866+
txbAttachmentsFolder.Text = folderBrowserDialog1.SelectedPath;
860867
}
861868
}
862869
}

0 commit comments

Comments
 (0)