none
How to send Excel.Range to HtmlMail RRS feed

  • Question

  • Hello, I have a question.
    I’m trying to send a particular part including cell format in a sheet to html mail.
    The way I’m trying to is that I match the value and html format with String.Format after creating cell format with html. 

    Here is link you can see my works.
    Link : http://vsto.tistory.com/entry/VSTO엑셀-급여명세서-HTML-태그메일-보내기끝

    But I think it’s not effective.

    While I looked into more effective methods, I’ve checked if I paste OutLook Body after copying in Excel, it is possible to paste cell format and the value with keeping cell Format.(using clipboard)
    Is there a method to program about this?

    I’m sure it’d be possible but I can’t figure out.


    http://vsto.tistory.com
    Wednesday, May 18, 2011 8:40 AM

Answers

All replies

  •  I read below link luckily.
    I appreciate it to Tim Li I can understand and solve the things I wanted easily.
    I guess I’m improving my skills for VSTO after visiting VSTO Forum, I’m not good at English, though.
    The source code I have to write is decreased substantially.
    But I still have some questions.
    How should I send from Excel to OutLook by using ClipBoard?
    Please, let me know whether it’s possible or not.
    I created below code with Tim Li's reply.
      private static void sendMail()
    
      {
    
       Outlook.Application app = new Outlook.Application();
    
       Outlook.MailItem mailitem = (Outlook.MailItem)app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
    
    
    
       mailitem.Subject = Globals.Sheet3.Range["a1", Type.Missing].Text.ToString();
    
    
    
       mailitem.To = Globals.Sheet3.VSTOMAIL.Value2.ToString();
    
    
    
       Globals.ThisWorkbook.PublishObjects.Add(Microsoft.Office.Interop.Excel.XlSourceType.xlSourceRange, @"C:\kesung\test.htm",
    
        Type.Missing, "testa", Excel.XlHtmlType.xlHtmlStatic, Type.Missing, Type.Missing).Publish(true);
    
    
    
       StreamReader sr = new StreamReader(@"C:\kesung\test.htm", Encoding.Default);
    
    
    
       mailitem.HTMLBody = sr.ReadToEnd();
    
    
    
       mailitem.Display(false);
    
       ((Outlook._MailItem)mailitem).Send();
    
       mailitem = null;
    
       app = null;
    
      }
    
    

    Tuesday, May 24, 2011 1:15 AM
  • Hi VSTO_Beginner,

    Please take a look at this thread:

    http://social.msdn.microsoft.com/Forums/en-US/outlookdev/thread/5248288a-0f86-4fe7-8235-2ccb85d2b014

    Sue says that if we want to paste formatted information from the clipboard into an Outlook item, we need to go through WordEditor.
    You can take a try. Hope this can give you the hint.
    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by VSTO_Beginner Tuesday, May 24, 2011 4:14 AM
    Tuesday, May 24, 2011 2:48 AM
  • Thank you Very much^^

    혹시 한국분이실까봐 한국어도 같이 답니다..

    항상 Bruse Song님 덕분에 많은 걸 배워갑니다..

    제 영어실력이 형편없어서..이렇게 한국어로 감사의 표현을 대신합니다..

    정말 너무 너무 감사합니다...

     

     


    http://vsto.tistory.com
    Tuesday, May 24, 2011 4:17 AM