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

  • had you try to specify a internet URL? the problem can be the machine's security settings Apr 9, 2012 at 5:58
  • I do not know how use insert images from the internet into a Word!
    – ar.gorgin
    Apr 9, 2012 at 6:22
  • did you try to use something like this: WebClient Client = new WebClient (); Client.DownloadFile("i.stackoverflow.com/Content/Img/stackoverflow-logo-250.png", @"C:\folder\stackoverflowlogo.png"); Than add the image from your local path? Apr 9, 2012 at 6:28
  • I don't save image in local path.
    – ar.gorgin
    Apr 9, 2012 at 6:32
  • can you save it in local path or not? Apr 9, 2012 at 6:55

1 Answer 1


I add Credentials for HttpWebRequest .

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

It is work for me :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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