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

  • Home
  • SEARCH
  • 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 8998525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:02:46+00:00 2026-06-16T00:02:46+00:00

I am trying to send innerhtml of a particular div to email(in Codeigniter framework).

  • 0

I am trying to send innerhtml of a particular div to email(in Codeigniter framework).

I got the inner html of the div using jquery and transfered the data to the controller using ajax.

The mail worked, but my problem is html classes, style tags(except the inline styles i wrote in the view file html), style sheet are not working.

Is there any way to add my style.css file in the email content? I will be ok even if the tag works properly, which I had put at the begining of the <head> section.

Please help, here is my code.

Ajax code for transfering html to controller:

<script type="text/javascript">
    $(function() {
  $('#sendmail').click(function(e) {

        e.preventDefault();
        $.ajax({
              url:'<?php echo site_url();?>/welcome/send',
              type:'POST',
              data:{'message':$('#body').html(),'subject':'Subject of your e-mail'},
              success:function(data) {
                    alert('You data has been successfully e-mailed');
                    alert('Your server-side script said: ' + data);
              }
        });
  });
});

</script>

Code in the controller
public function send()
{

            $nome = $this->input->post('message');

           $config = array(
            'protocol' => 'smtp',
            'smtp_host' => 'send.one.com',
            'smtp_port' => '2525',
            'smtp_user' => 'akhil.ns@cymose-tech.com',
            'smtp_pass' => 'akhil123',
            'charset' => 'utf-8',
            'wordwrap' => TRUE,
            'mailtype' => 'html'
        );
        $this->load->library('email', $config);

        $this->email->set_newline("\r\n");
        $this->email->from('akhil.ns@cymose-tech.com', 'The Wanderers');
        $this->email->to('shabasy002@gmail.com');

        $this->email->subject('The Wanderers Proforma Invoice ');

        $formatedMessag ='';

    $formatedMessag = '<html><head><link rel="stylesheet" type="text/css" href="http://localhost/study/extra/style.css"></head><body><style type="text/css">p{color:#cccccc;font-weight:bold;}</style>';
        $formatedMessag .= $nome.'</body></html>';

        $this->email->message($formatedMessag);

        if ($this->email->send()) {

            echo $formatedMessag;

            }

}
  • 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-06-16T00:02:47+00:00Added an answer on June 16, 2026 at 12:02 am

    As far as I know, no email clients allow loading of external stylesheets for HTML emails.

    Ultimately, this means that you have to declare the styles in the head of the document, e.g.

    <head>
        <style>
            body { background: black; color: white; }
        </style>
    </head>
    

    However, some email clients (Well, pretty much just outlook) don’t even allow some styles defined in the head of the document, which means inlining styles like such:

    <body style="background: black; color: white;"></body>
    

    (a little bit of me inside just died)

    There are also a number of problems with using even inline CSS in HTML emails as some clients (again mostly outlook) don’t support simple CSS features like float’s. Which ends up meaning you have to code the newsletter with tables to ensure it works for the majority of people.

    For more information see this article (or just Google around):
    http://www.sitepoint.com/code-html-email-newsletters/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I`m trying to send simple html page with form data to user with GET,
I am trying to send an email to customers with html form. here is
I am trying to send data as a model from an html form to
Trying to send POST request on click event using jQuery with no luck. Here
am trying send an array to php file using $_POST ,still always getting an
Trying to send some email in my C# app. I am behind a proxy
I am trying to send emails from smtps (secure smtp) using Indy and the
I'm trying to change the innerHTML of a div and fade it in when
I'm trying to pass the ID of a clicked DIV to a particular function
I'm trying to convert our current javascript framework to jQuery cause we'll need the

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.