login about faq

I seem to have an odd issue with using the SaveRelatedItem function, in that it doesn't always seem to save with a new filename when a file already exists, or, if it is, it is not returning this new filename using "GetRelatedFileName" after the save is finished.

The weird thing is, it seems to work sometimes, and other times it does not. Particularly with the filenames "image001.png" and "image002.png" it seems to have an issue - or at least those are two I have noticed. It also seems to be a problem more frequently with messages that are replies or forwards. What happens if when generating the random 4 characters to put on the end of the filename, it ends up with a filename which still already exists - would this cause the save to fail? Or would it keep trying to generate a unique name until it found one?

Here is my code (C#) - can anyone shed any furhter light on this, please?

POPemail.OverwriteExisting = false;

//now do embedded images int embed_count = POPemail.NumRelatedItems;

for(int loop_attach=0; loop_attach<embed_count;loop_attach++) { //MessageBox.Show(attachments[loop_attach].Name); string EmbedFileName = POPemail.GetRelatedFilename(loop_attach); POPemail.SaveRelatedItem(loop_attach,attachment_path); string SavedEmbedFileName = POPemail.GetRelatedFilename(loop_attach); email.addAttachment(attachment_path+"\"+SavedEmbedFileName+"(****)"+SavedEmbedFileName); }

asked Jan 21 '14 at 04:14

Mayb2Moro's gravatar image

Mayb2Moro
12

edited Jan 21 '14 at 07:30

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×184
×1

Asked: Jan 21 '14 at 04:14

Seen: 513 times

Last updated: Jan 21 '14 at 07:30

powered by OSQA