Send Mail HTML Table body & Attachment Text file
Clash Royale CLAN TAG#URR8PPP
I am try to send a mail with HTML table by reading data from a text file. The table is getting formatted properly and can be seen in mail body but i also want the same text file to be send in same mail as an attachment.
Here is the code I am using:
awk -F '|' '
BEGIN
print "From: abcdef@xyz.com"
print "To: abcdef@xyz.com"
print "MIME-Version: 1.0"
print "Content-Type: text/html"
print "Subject: Utilization Report"
print "<html><body><font face=verdana size=2 color=black ></br></br> Body of mail. </br> </br></br> <B> Notes of mail.</b></br></br> "
print "<table border=1 cellspacing=1 cellpadding=1 height="75">"
!/^#/ && /^S/
print "<tr>"
for ( i = 1; i <= NF; i++ )
print "<td> <center> <font face=verdana size=2> " $i " </center></td>"
print "</tr>"
!/^#/ && !/^S/
print "<tr>"
for ( i = 1; i <= NF; i++ )
print "<td> <center> <font face=verdana size=2> " $i " </center></td>"
print "</tr>"
END
print "</table></body></html>"
' /path-of-file/filename.txt | /usr/sbin/sendmail -t uuencode /path-of-file/filename.txt
awk sendmail
add a comment |
I am try to send a mail with HTML table by reading data from a text file. The table is getting formatted properly and can be seen in mail body but i also want the same text file to be send in same mail as an attachment.
Here is the code I am using:
awk -F '|' '
BEGIN
print "From: abcdef@xyz.com"
print "To: abcdef@xyz.com"
print "MIME-Version: 1.0"
print "Content-Type: text/html"
print "Subject: Utilization Report"
print "<html><body><font face=verdana size=2 color=black ></br></br> Body of mail. </br> </br></br> <B> Notes of mail.</b></br></br> "
print "<table border=1 cellspacing=1 cellpadding=1 height="75">"
!/^#/ && /^S/
print "<tr>"
for ( i = 1; i <= NF; i++ )
print "<td> <center> <font face=verdana size=2> " $i " </center></td>"
print "</tr>"
!/^#/ && !/^S/
print "<tr>"
for ( i = 1; i <= NF; i++ )
print "<td> <center> <font face=verdana size=2> " $i " </center></td>"
print "</tr>"
END
print "</table></body></html>"
' /path-of-file/filename.txt | /usr/sbin/sendmail -t uuencode /path-of-file/filename.txt
awk sendmail
You will need to construct a "multipart" message. Examples can be found. Been there, done that, but never with awk.
– Gerard H. Pille
Jan 28 at 22:32
This feels like it would be difficult to do in awk. If awk is a requirement, it should be a tag. You can click the edit button under your post to add that tag. If it's not a requirement, what else would you be open to? bash, zsh, python, perl, and ruby are all options that feel to me like they'd be easier than awk. Of course, I'm not an awk enthusiast; it could be someone who uses awk all the time would know better how to do that - which is one of the two reasons you should have the awk tag if you need it to be awk.
– Ed Grimm
Jan 28 at 23:37
Thanks for your reply Gerard.
– dumpi16
Jan 29 at 14:17
Thanks you Ed, I will look for some work around. Menawhile, I have added the tag ' awk'.
– dumpi16
Jan 29 at 14:19
add a comment |
I am try to send a mail with HTML table by reading data from a text file. The table is getting formatted properly and can be seen in mail body but i also want the same text file to be send in same mail as an attachment.
Here is the code I am using:
awk -F '|' '
BEGIN
print "From: abcdef@xyz.com"
print "To: abcdef@xyz.com"
print "MIME-Version: 1.0"
print "Content-Type: text/html"
print "Subject: Utilization Report"
print "<html><body><font face=verdana size=2 color=black ></br></br> Body of mail. </br> </br></br> <B> Notes of mail.</b></br></br> "
print "<table border=1 cellspacing=1 cellpadding=1 height="75">"
!/^#/ && /^S/
print "<tr>"
for ( i = 1; i <= NF; i++ )
print "<td> <center> <font face=verdana size=2> " $i " </center></td>"
print "</tr>"
!/^#/ && !/^S/
print "<tr>"
for ( i = 1; i <= NF; i++ )
print "<td> <center> <font face=verdana size=2> " $i " </center></td>"
print "</tr>"
END
print "</table></body></html>"
' /path-of-file/filename.txt | /usr/sbin/sendmail -t uuencode /path-of-file/filename.txt
awk sendmail
I am try to send a mail with HTML table by reading data from a text file. The table is getting formatted properly and can be seen in mail body but i also want the same text file to be send in same mail as an attachment.
Here is the code I am using:
awk -F '|' '
BEGIN
print "From: abcdef@xyz.com"
print "To: abcdef@xyz.com"
print "MIME-Version: 1.0"
print "Content-Type: text/html"
print "Subject: Utilization Report"
print "<html><body><font face=verdana size=2 color=black ></br></br> Body of mail. </br> </br></br> <B> Notes of mail.</b></br></br> "
print "<table border=1 cellspacing=1 cellpadding=1 height="75">"
!/^#/ && /^S/
print "<tr>"
for ( i = 1; i <= NF; i++ )
print "<td> <center> <font face=verdana size=2> " $i " </center></td>"
print "</tr>"
!/^#/ && !/^S/
print "<tr>"
for ( i = 1; i <= NF; i++ )
print "<td> <center> <font face=verdana size=2> " $i " </center></td>"
print "</tr>"
END
print "</table></body></html>"
' /path-of-file/filename.txt | /usr/sbin/sendmail -t uuencode /path-of-file/filename.txt
awk sendmail
awk sendmail
edited Jan 29 at 14:16
dumpi16
asked Jan 28 at 21:19
dumpi16dumpi16
1
1
You will need to construct a "multipart" message. Examples can be found. Been there, done that, but never with awk.
– Gerard H. Pille
Jan 28 at 22:32
This feels like it would be difficult to do in awk. If awk is a requirement, it should be a tag. You can click the edit button under your post to add that tag. If it's not a requirement, what else would you be open to? bash, zsh, python, perl, and ruby are all options that feel to me like they'd be easier than awk. Of course, I'm not an awk enthusiast; it could be someone who uses awk all the time would know better how to do that - which is one of the two reasons you should have the awk tag if you need it to be awk.
– Ed Grimm
Jan 28 at 23:37
Thanks for your reply Gerard.
– dumpi16
Jan 29 at 14:17
Thanks you Ed, I will look for some work around. Menawhile, I have added the tag ' awk'.
– dumpi16
Jan 29 at 14:19
add a comment |
You will need to construct a "multipart" message. Examples can be found. Been there, done that, but never with awk.
– Gerard H. Pille
Jan 28 at 22:32
This feels like it would be difficult to do in awk. If awk is a requirement, it should be a tag. You can click the edit button under your post to add that tag. If it's not a requirement, what else would you be open to? bash, zsh, python, perl, and ruby are all options that feel to me like they'd be easier than awk. Of course, I'm not an awk enthusiast; it could be someone who uses awk all the time would know better how to do that - which is one of the two reasons you should have the awk tag if you need it to be awk.
– Ed Grimm
Jan 28 at 23:37
Thanks for your reply Gerard.
– dumpi16
Jan 29 at 14:17
Thanks you Ed, I will look for some work around. Menawhile, I have added the tag ' awk'.
– dumpi16
Jan 29 at 14:19
You will need to construct a "multipart" message. Examples can be found. Been there, done that, but never with awk.
– Gerard H. Pille
Jan 28 at 22:32
You will need to construct a "multipart" message. Examples can be found. Been there, done that, but never with awk.
– Gerard H. Pille
Jan 28 at 22:32
This feels like it would be difficult to do in awk. If awk is a requirement, it should be a tag. You can click the edit button under your post to add that tag. If it's not a requirement, what else would you be open to? bash, zsh, python, perl, and ruby are all options that feel to me like they'd be easier than awk. Of course, I'm not an awk enthusiast; it could be someone who uses awk all the time would know better how to do that - which is one of the two reasons you should have the awk tag if you need it to be awk.
– Ed Grimm
Jan 28 at 23:37
This feels like it would be difficult to do in awk. If awk is a requirement, it should be a tag. You can click the edit button under your post to add that tag. If it's not a requirement, what else would you be open to? bash, zsh, python, perl, and ruby are all options that feel to me like they'd be easier than awk. Of course, I'm not an awk enthusiast; it could be someone who uses awk all the time would know better how to do that - which is one of the two reasons you should have the awk tag if you need it to be awk.
– Ed Grimm
Jan 28 at 23:37
Thanks for your reply Gerard.
– dumpi16
Jan 29 at 14:17
Thanks for your reply Gerard.
– dumpi16
Jan 29 at 14:17
Thanks you Ed, I will look for some work around. Menawhile, I have added the tag ' awk'.
– dumpi16
Jan 29 at 14:19
Thanks you Ed, I will look for some work around. Menawhile, I have added the tag ' awk'.
– dumpi16
Jan 29 at 14:19
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f497294%2fsend-mail-html-table-body-attachment-text-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f497294%2fsend-mail-html-table-body-attachment-text-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You will need to construct a "multipart" message. Examples can be found. Been there, done that, but never with awk.
– Gerard H. Pille
Jan 28 at 22:32
This feels like it would be difficult to do in awk. If awk is a requirement, it should be a tag. You can click the edit button under your post to add that tag. If it's not a requirement, what else would you be open to? bash, zsh, python, perl, and ruby are all options that feel to me like they'd be easier than awk. Of course, I'm not an awk enthusiast; it could be someone who uses awk all the time would know better how to do that - which is one of the two reasons you should have the awk tag if you need it to be awk.
– Ed Grimm
Jan 28 at 23:37
Thanks for your reply Gerard.
– dumpi16
Jan 29 at 14:17
Thanks you Ed, I will look for some work around. Menawhile, I have added the tag ' awk'.
– dumpi16
Jan 29 at 14:19