SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Document Library with column type Hyperlink or Picture (Signature).

How to insert (Signature) into your Word document?

I find this link for insert Picture into word.

I problem is : How do insert the internet picture(url) in word ?

I use this code

  ImagePart imagePart = mainPart.AddImagePart(ImagePartType.Jpeg);
  //Send an HTTP request and get the image at the URL as an HTTP response
  HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(fileName);
   WebResponse myResp = myReq.GetResponse();

  //Get a stream from the webresponse
  Stream stream = myResp.GetResponseStream();


but i get error

The remote server returned an error: (401) Unauthorized

share|improve this question
had you try to specify a internet URL? the problem can be the machine's security settings – Salvatore Di Fazio Apr 9 '12 at 5:58
I do not know how use insert images from the internet into a Word! – ar.gorgin Apr 9 '12 at 6:22
did you try to use something like this: WebClient Client = new WebClient (); Client.DownloadFile("";, @"C:\folder\stackoverflowlogo.png"); Than add the image from your local path? – Salvatore Di Fazio Apr 9 '12 at 6:28
I don't save image in local path. – ar.gorgin Apr 9 '12 at 6:32
can you save it in local path or not? – Salvatore Di Fazio Apr 9 '12 at 6:55
up vote 0 down vote accepted

I add Credentials for HttpWebRequest .

myReq.UseDefaultCredentials = true;
myReq.PreAuthenticate = true;
myReq.Credentials = CredentialCache.DefaultCredentials;

It is work for me :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.