PC Review


Reply
Thread Tools Rate Thread

COMException saving contact picture

 
 
Battistaar
Guest
Posts: n/a
 
      3rd Mar 2009
Hi all, in my software i need to retrieve outlook contact picture, this is my
code to do that in c#:

private Image getOutlookPicture(Outlook.ContactItem contact)
{
Image img;
img = Properties.Resources.user; //default image
foreach (Outlook.Attachment at in contact.Attachments)
{
if (at.FileName == "ContactPicture.jpg" || at.FileName ==
"ContactPhoto")
{
string fullName ="temp.jpg";
at.SaveAsFile(fullName);
FileStream tempStream = new FileStream(fullName,
FileMode.Open);
img = Image.FromStream(tempStream);
tempStream.Close();
File.Delete(fullName);
}
}
return img;
}

all work fine when i find a ContactPhoto, with ContactPicture.jpg it throws
a COMException saying that it is unamble to save the attachment and
suggesting me to control folder's permission. I'm an amministrator user, and
with ContactPhoto file all work fine, so it's strange.
any idea?
and anyone knows why are some picture saved as ContactPicture.jpg and
someother as ContactPhoto?
 
Reply With Quote
 
 
 
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      3rd Mar 2009
Specify a fully qualified path name instead of just temp.jpg.
Chances are your current directory is one of the Program Files subfolder,
and normally users have no write access to that folder or any of its
subfolders.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Battistaar" <(E-Mail Removed)> wrote in message
news:BE89FC34-70F4-4D3E-953B-(E-Mail Removed)...
> Hi all, in my software i need to retrieve outlook contact picture, this is
> my
> code to do that in c#:
>
> private Image getOutlookPicture(Outlook.ContactItem contact)
> {
> Image img;
> img = Properties.Resources.user; //default image
> foreach (Outlook.Attachment at in contact.Attachments)
> {
> if (at.FileName == "ContactPicture.jpg" || at.FileName ==
> "ContactPhoto")
> {
> string fullName ="temp.jpg";
> at.SaveAsFile(fullName);
> FileStream tempStream = new FileStream(fullName,
> FileMode.Open);
> img = Image.FromStream(tempStream);
> tempStream.Close();
> File.Delete(fullName);
> }
> }
> return img;
> }
>
> all work fine when i find a ContactPhoto, with ContactPicture.jpg it
> throws
> a COMException saying that it is unamble to save the attachment and
> suggesting me to control folder's permission. I'm an amministrator user,
> and
> with ContactPhoto file all work fine, so it's strange.
> any idea?
> and anyone knows why are some picture saved as ContactPicture.jpg and
> someother as ContactPhoto?



 
Reply With Quote
 
Battistaar
Guest
Posts: n/a
 
      3rd Mar 2009
it doesn't work, i tried, and with ContactPhoto attachment it works with this
path

"Dmitry Streblechenko" wrote:

> Specify a fully qualified path name instead of just temp.jpg.
> Chances are your current directory is one of the Program Files subfolder,
> and normally users have no write access to that folder or any of its
> subfolders.
>
> --
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
> -
> "Battistaar" <(E-Mail Removed)> wrote in message
> news:BE89FC34-70F4-4D3E-953B-(E-Mail Removed)...
> > Hi all, in my software i need to retrieve outlook contact picture, this is
> > my
> > code to do that in c#:
> >
> > private Image getOutlookPicture(Outlook.ContactItem contact)
> > {
> > Image img;
> > img = Properties.Resources.user; //default image
> > foreach (Outlook.Attachment at in contact.Attachments)
> > {
> > if (at.FileName == "ContactPicture.jpg" || at.FileName ==
> > "ContactPhoto")
> > {
> > string fullName ="temp.jpg";
> > at.SaveAsFile(fullName);
> > FileStream tempStream = new FileStream(fullName,
> > FileMode.Open);
> > img = Image.FromStream(tempStream);
> > tempStream.Close();
> > File.Delete(fullName);
> > }
> > }
> > return img;
> > }
> >
> > all work fine when i find a ContactPhoto, with ContactPicture.jpg it
> > throws
> > a COMException saying that it is unamble to save the attachment and
> > suggesting me to control folder's permission. I'm an amministrator user,
> > and
> > with ContactPhoto file all work fine, so it's strange.
> > any idea?
> > and anyone knows why are some picture saved as ContactPicture.jpg and
> > someother as ContactPhoto?

>
>
>

 
Reply With Quote
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      4th Mar 2009
What is your code that uses the full path and still does not work??

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Battistaar" <(E-Mail Removed)> wrote in message
news:5CD6DB2B-83D4-42C7-B2B5-(E-Mail Removed)...
> it doesn't work, i tried, and with ContactPhoto attachment it works with
> this
> path
>
> "Dmitry Streblechenko" wrote:
>
>> Specify a fully qualified path name instead of just temp.jpg.
>> Chances are your current directory is one of the Program Files subfolder,
>> and normally users have no write access to that folder or any of its
>> subfolders.
>>
>> --
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>> -
>> "Battistaar" <(E-Mail Removed)> wrote in message
>> news:BE89FC34-70F4-4D3E-953B-(E-Mail Removed)...
>> > Hi all, in my software i need to retrieve outlook contact picture, this
>> > is
>> > my
>> > code to do that in c#:
>> >
>> > private Image getOutlookPicture(Outlook.ContactItem contact)
>> > {
>> > Image img;
>> > img = Properties.Resources.user; //default image
>> > foreach (Outlook.Attachment at in contact.Attachments)
>> > {
>> > if (at.FileName == "ContactPicture.jpg" || at.FileName
>> > ==
>> > "ContactPhoto")
>> > {
>> > string fullName ="temp.jpg";
>> > at.SaveAsFile(fullName);
>> > FileStream tempStream = new FileStream(fullName,
>> > FileMode.Open);
>> > img = Image.FromStream(tempStream);
>> > tempStream.Close();
>> > File.Delete(fullName);
>> > }
>> > }
>> > return img;
>> > }
>> >
>> > all work fine when i find a ContactPhoto, with ContactPicture.jpg it
>> > throws
>> > a COMException saying that it is unamble to save the attachment and
>> > suggesting me to control folder's permission. I'm an amministrator
>> > user,
>> > and
>> > with ContactPhoto file all work fine, so it's strange.
>> > any idea?
>> > and anyone knows why are some picture saved as ContactPicture.jpg and
>> > someother as ContactPhoto?

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to include contact picture in a contact list print-out? =?Utf-8?B?ZWRqb2hu?= Microsoft Outlook Contacts 0 29th Dec 2005 09:12 PM
How do I print a contact directory including contact's picture? =?Utf-8?B?QWxlam8gR29tZXo=?= Microsoft Outlook Contacts 3 17th Dec 2005 07:28 PM
How to include contact picture in a contact list print-out? =?Utf-8?B?ZGF2ZXI=?= Microsoft Outlook Discussion 3 14th Jul 2005 12:16 PM
imbed picture in contact form and add button to browse to picture file Rasta Microsoft Outlook Form Programming 6 20th Apr 2005 12:14 AM
Saving picture order in my picture folder BRC Windows XP Photos 1 18th Sep 2004 04:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:39 PM.