-2

enter image description hereAdding SVG image code in html code and add html in htmlbody after that sending email so image is not showing

here is my code

---- code ---

MimeMessage emailMessage = new MimeMessage();
                MailboxAddress emailFrom = new MailboxAddress("Vcare", "[email protected]");
                emailMessage.From.Add(emailFrom);
                MailboxAddress emailTo = new MailboxAddress(emailData.EmailToName, emailData.EmailToId);
                emailMessage.To.Add(emailTo);
                emailMessage.Subject = emailData.EmailSubject;
                BodyBuilder emailBodyBuilder = new BodyBuilder();
                

                var htmlData = @"<table cellpadding='0' cellspacing='0' width='650' style='background - color:#f5f5f5;margin:0 auto;color:#666465;min-width:650px'>"+
    "<tbody><tr style='background-color:#00a8da; height:61px'>"+

           "<td style='vertical-align:middle'>"+

                "<table width ='100%' cellpadding='0' cellspacing='0' height='60'><tbody><tr><td style='width:5%'></td>"+
                                "<td style ='color:#fff;width:72%;font-size:14px;letter-spacing:1px'><b style='font-size: 17px;'> New Account Details</b></td><td align='right'>"+

" ##Date "+ "" + "<svg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' width='100%' viewBox='0 0 698 180' enable - background='new 0 0 698 180' xml: space='preserve'>"+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ "" + "" + "
Dear ##UserFirstName,

" + "Congratulations on opening your account successfully at VCare(EHR).Your account is now active and you may login from our home page.
"+ "
Within the members area you can submit and review your listings, view detailed statistics, edit your account details and much more.
"+ "
Login Details:
Email:##userName
"+ " Password:</ b > ##userPassword
"+ " http://ehr-testingdev.signupdemo.com/
"+ "Should you require any help related to your account then do not hesitate to contact us.
"+ "
Regards

Support Team
"+ ""+ ""+

                                       "<td width='22%' style='color: #fff;line-height:22px;vertical-align:middle;font-family:Open Sans,sans-serif'> Let's Connect!</td>"+
                                              "<td width='100%' style='vertical-align:middle; padding-left: 385px;'>"+

                                                    "<a style='' href='http://twitter.com' target='_blank' alt='Twitter' class='CToWUd'> <svg xmlns='http://www.w3.org/2000/svg'  viewBox='0 0 48 48' width='48px' height='48px'><path fill='#3F51B5' d='M42,37c0,2.762-2.238,5-5,5H11c-2.761,0-5-2.238-5-5V11c0-2.762,2.239-5,5-5h26c2.762,0,5,2.238,5,5V37z'/><path fill='#FFF' d='M34.368,25H31v13h-5V25h-3v-4h3v-2.41c0.002-3.508,1.459-5.59,5.592-5.59H35v4h-2.287C31.104,17,31,17.6,31,18.723V21h4L34.368,25z'/></svg> </a>" +

                "</td>" +
                                    "<td width='10%' style='vertical-align:middle; display: flex; justify-content: center;'>"+
                                        "<a style='margin-left: 0px;' href='https://www.facebook.com' target='_blank' alt='Facebook' class='CToWUd'> <svg xmlns='http://www.w3.org/2000/svg' width='655.359' height='655.359' fill-rule='evenodd' clip-rule='evenodd' image-rendering='optimizeQuality' shape-rendering='geometricPrecision' text-rendering='geometricPrecision' viewBox='0 0 6.827 6.827'><rect width='6.827' height='6.827' fill='#0a93e2' rx='1.456' ry='1.456'/><path fill='#fff' d='M5.49009 2.3776c-0.147055,0.065189 -0.305406,0.109406 -0.47126,0.129142 0.169453,-0.101665 0.299421,-0.262402 0.361008,-0.453976 -0.158654,0.0938819 -0.334398,0.16228 -0.521224,0.199079 -0.149701,-0.159587 -0.363071,-0.259126 -0.599165,-0.259126 -0.45337,0 -0.820579,0.367598 -0.820579,0.820579 0,0.0642559 0.00711024,0.127079 0.021185,0.187126 -0.681961,-0.0343504 -1.28679,-0.361028 -1.69143,-0.857681 -0.0708268,0.121335 -0.111138,0.262335 -0.111138,0.412661 0,0.284827 0.144882,0.536122 0.364846,0.683177 -0.1345,-0.00420866 -0.260886,-0.041248 -0.371744,-0.102835 0,0.00359843 0,0.0068937 0,0.0104961 0,0.397437 0.28298,0.72915 0.658323,0.804508 -0.0687008,0.0188228 -0.141303,0.0289921 -0.216055,0.0289921 -0.0528504,0 -0.104268,-0.00511811 -0.154535,-0.0146811 0.104657,0.326051 0.407697,0.563295 0.766882,0.569866 -0.280921,0.220244 -0.634752,0.351142 -1.01935,0.351142 -0.0664016,0 -0.131807,-0.00357874 -0.19576,-0.0113228 0.363091,0.232799 0.794343,0.368748 1.2578,0.368748 1.5095,0 2.3352,-1.25067 2.3352,-2.33511 0,-0.035563 -0.000909449,-0.0708465 -0.00236614,-0.10611 0.160413,-0.115673 0.299421,-0.260276 0.40937,-0.424677z'/></svg></a>" +
                "</td>" +
                                    "<td width ='50%'></td>"+

                                "</tr></td></tr></tbody></table></td></tr></tbody ></table> ";
                var email = @"##userName";
                var pass = @"##userPassword";
                var userFirstName = @"##UserFirstName";
                var dateTime = DateTime.Now.ToString("dd MMM , yyyy");
                var emailHtmlData = htmlData.Replace(email.ToString(), emailData.EmailToId);
                var emailHtmlData1 = emailHtmlData.Replace(pass.ToString(), emailData.EmailToPassword);
                var emailHtmlData2 = emailHtmlData1.Replace(userFirstName.ToString(), emailData.EmailToName).Replace(@"##Date",dateTime);

                //str.Close();

                   emailBodyBuilder.HtmlBody = emailHtmlData2;
                // emailBodyBuilder.TextBody = MailText;// emailData.EmailBody;
                emailMessage.Body = emailBodyBuilder.ToMessageBody();

                SmtpClient emailClient = new SmtpClient();
                emailClient.Connect("smtp.hostinger.com", 465, true);
                emailClient.Authenticate("[email protected]", "1234");
                emailClient.Send(emailMessage);
                emailClient.Disconnect(true);
                emailClient.Dispose();

1 Answer 1

0

It's very difficult to work out your problem here, but, SVGs are not well supported in email. https://www.caniemail.com/features/image-svg/

You should embed the image via an img tag:

<img src="https://www.path.com/to/image.png" width="x" height="y" alt="xyz" />

The image should be uploaded to a publicly available location.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.