×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Outlook RTF format image attachment copy/paste problem

Outlook RTF format image attachment copy/paste problem

Outlook RTF format image attachment copy/paste problem

(OP)
I have an image editing app, and the problem is with paste functionality. It's working fine if I copy paste from Paint, Windows Explorer, Outlook 2007, Outlook 2010... Drag and drop also works fine, but if I try to copy/paste from Outlook 2010 and mail is in RTF it doesn't work. So it works on 2007 when in RTF, or 2007 and 2010 when in other formats, but in 2010 it doesn't. I've tried it on another computer also Outlook 2010 RTF and it does work there. So the problem is two Outlook 2010 don't behave the same. When I try pasting I get an icon of the image and image name. Same thing happens in Paint. So to sum up: Outlook 2007 - all mail formats copy/paste working Outlook 2010 14.0.5128.5000 - all mail formats copy/paste working Outlook 2010 14.0.6106.5005 - RTF attachments copy/paste and drag and drop not working.

For the part of my pasting functionality (for Outlook) I've used this code http://www.codeproject.com/KB/office...rop_in_cs.aspx and modified it (fixed errors etc.).

Could it be that one version of Outlook has a bug(because same thing happens when pasting to Paint)?

Does someone have a code that 100% works so I can test if it's a version bug?

edit: Here's the two files attached: http://www.sendspace.com/file/s7iyns here's the code that handles pasting(openMimage opens a file array, and open Bmp opens a bitmap data object):

private void doPaste()
{
try
{
if (Clipboard.ContainsFileDropList())
{
System.Collections.Specialized.StringCollection returnList = Clipboard.GetFileDropList();
string[] mFiles = new string[returnList.Count];
int i = 0;
foreach (string file in returnList)
{
mFiles[i++] = file;
}
openMImages(mFiles, true);
}
else if (Clipboard.ContainsImage())
{
try
{
Bitmap clipBmp = new Bitmap((Bitmap)Clipboard.GetImage());
openBmp(clipBmp);
}
catch (Exception extExp)
{
MessageBox.Show("External exception: " + extExp.Message);
}

}
else
{
OutlookDataObject dataObject = new OutlookDataObject(Clipboard.GetDataObject());
if (dataObject != null)
{
string[] filenames = (string[])dataObject.GetData("FileGroupDescriptorW");
MemoryStream[] filestreams = (MemoryStream[])dataObject.GetData("FileContents");
int countFiles = 0;
String debug_data = "";
for (int fileIndex = 0; fileIndex < filenames.Length; fileIndex++)
{
debug_data += filenames[fileIndex];
string filename = filenames[fileIndex];
if (Path.GetExtension(filename) == ".jpg" || Path.GetExtension(filename) == ".JPG"
|| Path.GetExtension(filename) == ".png" || Path.GetExtension(filename) == ".PNG"
|| Path.GetExtension(filename) == ".gif" || Path.GetExtension(filename) == ".GIF"
|| Path.GetExtension(filename) == ".tif" || Path.GetExtension(filename) == ".tif"
|| Path.GetExtension(filename) == ".tiff" || Path.GetExtension(filename) == ".tiff"
|| Path.GetExtension(filename) == ".bmp" || Path.GetExtension(filename) == ".BMP")
{
countFiles++;
}
}
string[] mFiles = new string[countFiles];


if (filenames.Length <= 0)
{
MessageBox.Show("You can only copy/paste images.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
int i = 0;
for (int fileIndex = 0; fileIndex < filenames.Length; fileIndex++)
{
//use the fileindex to get the name and data stream
string filename = filenames[fileIndex];
if (Path.GetExtension(filename) == ".jpg" || Path.GetExtension(filename) == ".JPG"
|| Path.GetExtension(filename) == ".png" || Path.GetExtension(filename) == ".PNG"
|| Path.GetExtension(filename) == ".gif" || Path.GetExtension(filename) == ".GIF"
|| Path.GetExtension(filename) == ".tif" || Path.GetExtension(filename) == ".tif"
|| Path.GetExtension(filename) == ".tiff" || Path.GetExtension(filename) == ".tiff"
|| Path.GetExtension(filename) == ".bmp" || Path.GetExtension(filename) == ".BMP")
{
if (countFiles == 1)
{
Bitmap clipBmp = new Bitmap(filestreams[fileIndex]);
openBmp(clipBmp);
}
else
{
Bitmap tempForSave = new Bitmap(filestreams[fileIndex]);
string tempPathForSave = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
ImageEditor.saveJpeg(tempPathForSave + "\\" + Path.GetFileNameWithoutExtension(filename) + ".jpg", tempForSave, 100);
mFiles[i++] = tempPathForSave + "\\" + Path.GetFileNameWithoutExtension(filename) + ".jpg";
}
}
}
if (countFiles > 1)
{
openMImages(mFiles, true);
}
}
}
else
{
MessageBox.Show("You can only copy/paste images.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}

}
catch (Exception exp)
{
MessageBox.Show("Exception : " + exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close