Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions NSF2SQL/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,16 @@ private void bExportDocuments_Click(object sender, EventArgs ea)
MessageBox.Show("Select a database.");
return;
}
if (string.IsNullOrEmpty(txbAttachmentsFolder.Text))

string attachmentsFolder = txbAttachmentsFolder.Text;

if (string.IsNullOrEmpty(attachmentsFolder))
{
MessageBox.Show("Select a folder for attachments.");
return;
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);

if (result == DialogResult.Cancel) return;
}

int total = 0;
long startTicks = 0;
long lastTicks = 0;
Expand Down Expand Up @@ -367,19 +372,21 @@ private void bExportDocuments_Click(object sender, EventArgs ea)
for (int i = 0; i < total; i++)
{
object[] items = (object[])doc.Items;

foreach (NotesItem nItem in items)
if (!string.IsNullOrWhiteSpace(attachmentsFolder))
{
if (nItem.Name == "$FILE")
foreach (NotesItem nItem in items)
{
NotesItem file = doc.GetFirstItem("$File");
if (nItem.Name == "$FILE")
{
NotesItem file = doc.GetFirstItem("$File");

string fileName = ((object[])nItem.Values)[0].ToString();
string fileName = ((object[])nItem.Values)[0].ToString();

NotesEmbeddedObject attachfile = doc.GetAttachment(fileName);
NotesEmbeddedObject attachfile = doc.GetAttachment(fileName);

if (attachfile != null)
attachfile.ExtractFile($@"{txbAttachmentsFolder.Text}\{fileName}");
if (attachfile != null)
attachfile.ExtractFile($@"{attachmentsFolder}\{fileName}");
}
}
}

Expand All @@ -393,7 +400,7 @@ private void bExportDocuments_Click(object sender, EventArgs ea)
{
//get form
string form = ((string[])doc.GetItemValue("Form"))[0];

if (!tables.ContainsKey(form))
{
tables.Add(form, new Table(form));
Expand Down Expand Up @@ -856,7 +863,7 @@ private NotesSession initSession(string password)
private void btnBrowseAttachmentsFolder_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
txbAttachmentsFolder.Text = folderBrowserDialog1.SelectedPath;
txbAttachmentsFolder.Text = folderBrowserDialog1.SelectedPath;
}
}
}