Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 668867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:05:17+00:00 2026-05-14T00:05:17+00:00

I’ve added functionality to an application that prints out a bunch of information to

  • 0

I’ve added functionality to an application that prints out a bunch of information to a FixedDOcument and sends this off to the printer. This works just fine, however the request is that there be an in application function that emails the document using OUtlook and its here that I come unstuck. I’d very much like to just reuse the class that makes the fixed document for printing to generate the text for email, but I’m struggling to do this.

I’ve tried the following…

Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
MailItem email = (MailItem)(oApp.CreateItem(OlItemType.olMailItem));
email.Recipients.Add("someone@somewhere.com");
email.Subject = "Hello";
email.Body = "TEST";
FixedDocument doc = CreateReport(); //make my fixed document

//this doesn't work, and the parameters it takes suggest it never will
email.Attachments.Add(doc, OlAttachmentType.olByValue, 1, null); 
email.Send();

I can’t help but think I’m on completely the wrong tack here, but I don’t really want to have to write a bunch of new text formatting (since email.Body only takes a string) when I’ve already got the content formatted how I want it.

Note that the content is all textual, so I don’t really care if it gets sent as an attachment or as text in the emails body. Ideally if its sent as an attachment it won’t be saved anywhere permanently.

Any pointers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:05:18+00:00Added an answer on May 14, 2026 at 12:05 am

    Save the Fixed document to the users temporary folder, than put the full path name of the document in the attachment, send it, and then delete the document from temporary folder.

    Attachment Signature

    Attachment Add (
        [InAttribute] Object Source,
        [OptionalAttribute] [InAttribute] Object Type,
        [OptionalAttribute] [InAttribute] Object Position,
        [OptionalAttribute] [InAttribute] Object DisplayName
    )
    

    Source Parameter:

    Source
    The source of the attachment. This can be a file (represented by the full file system path with a file name) or an Outlook item that constitutes the attachment.
    

    Saving Document:

    String TempFoder = System.Environment.GetEnvironmentVariable("TEMP");
    String tempFileName = TempFoder + @"\TempFixedDocument.doc";
    FixedDocument.Save(tempFileName);
    

    Sending Email:

    Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
    MailItem email = (MailItem)(oApp.CreateItem(OlItemType.olMailItem));
    email.Recipients.Add("someone@somewhere.com");
    email.Subject = "Hello";
    email.Body = "TEST";
    FixedDocument doc = CreateReport(); //make my fixed document
    
    //this doesn't work, and the parameters it takes suggest it never will
    email.Attachments.Add(tempFileName, OlAttachmentType.olByValue, 1, null); 
    email.Send();
    

    Deleting Temp File:

    System.IO.File.Delete(tempFileName);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.