Embede multiple HTML files in e-mail body

Welcome Forums General PowerShell Q&A Embede multiple HTML files in e-mail body

This topic contains 5 replies, has 4 voices, and was last updated by

 
Participant
2 years, 7 months ago.

  • Author
    Posts
  • #38671

    Participant
    Points: 0
    Rank: Member

    Hi,
    I have five HTML files & try to embed all these to e-mail body.
    Example below:

    E-mail body must look like below:

    The below contains D1 information
    Embed 1.HTML

    The below contains D2 information
    Embed 2.HTML

    I wrote a script, but it is not getting me the desired output:
    $body = get-content .\content.htm
    $message.body = $body

    -Kalyan

  • #38676

    Participant
    Points: 10
    Rank: Member

    Do you need the name of each html file in email body or the contents of each html file in email body?

  • #38678

    Participant
    Points: 21
    Rank: Member
    $a = ""
    $a = $a + "BODY{background-color:white;FONT-SIZE: 8pt; FONT-FAMILY: verdana}"
    $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
    $a = $a + "TH{border-width: 1px;padding: 3px;border-style: solid;border-color: black;color: red;background-color:#CCCCCC}"
    $a = $a + "TD{border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color:white}"
    $a = $a + ""
    
    #somestuff
    
    get-process |ConvertTo-HTML -head $a | out-file test.htm
    
    #somemorestuff
    
    get-service |ConvertTo-HTML -head $a -body '' | out-file test.htm  -append
  • #38679

    Participant
    Points: 21
    Rank: Member

    There are supposed to be to html breaks in between the quoutes in the second command. forum removes them.

  • #38918

    Participant
    Points: 0
    Rank: Member

    Thanks. Worked fine.

    -Kalyan

  • #38919

    Participant
    Points: 0
    Rank: Member

    Doesn't this literally make two separate HTML files and cram them together in the same file giving the file two HEAD sections? I see that Vakat said it works, but is it the best way to do it?

The topic ‘Embede multiple HTML files in e-mail body’ is closed to new replies.