Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228

    Using VBA to send HTML Email - Unordered List indent issue

    I'm bashing my head into a wall over and over again here. For the life of me, I cannot figure out how to remove the indent on a <ul> item.



    The following link is where I am sourcing how to do it, however no matter what I do within my VB, the email comes up with about a full inch worth of an indent on the UL.

    http://www.w3schools.com/tags/tryit....ul_default_css

    I begin my code with

    Code:
    "<style>ul { display: block; list-style-type: disc; margin-top: 1em; margin-bottom: 1 em; margin-left: 0; margin-right: 0; padding-left: 0; }</style>"
    and then further down in the body where the UL is called

    Code:
    "<p><ul><li>Print this email and return it with your shipment.</li><b>OR</b><br><li>Include your Dealer Number, Serial Number and Claim Number with your shipment.</li></ul></p>"
    No matter what I change, the indentation doesn't move. See below...

    Click image for larger version. 

Name:	Indent Error.png 
Views:	11 
Size:	7.7 KB 
ID:	19251

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Can you post enough of your code that I can cut and paste it into a module for testing.

  3. #3
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Code:
    msg = "<style>ul { display: block; list-style-type: disc; margin-top: 1em; margin-bottom: 1 em; margin-left: 0; margin-right: 0; padding-left: 0; }</style>" _
    & "<p>Dear xx (Dealer: xx),</p>" _
    & "<p>This email is in regards to a parts return for:</p>" _
    & "<p><b>Part Number(s)</b>:<br>xxxxx</p>" _
    & "<p>Please follow the attached instructions for your return.</p>" _
    & "<p>In order for your claim to be processed, please be sure to:</p>" _
    & "<p><ul><li>Print this email and return it with your shipment.</li><b>OR</b><br><li>Include your Dealer Number, Serial Number and Claim Number with your shipment.</li></ul></p>" _
    & "<p>***** For <b><u>Canadian</u></b> shipments, write your Dealer Number and Claim Number on the <b><u>OUTSIDE</u></b> or the container.</p>"
    This should be enough to test it out. I did try separating style into a header and the rest in a body, didn't make a difference.

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    what about the code that sets up the email I'm only asking because there are a few ways you can do the email and that might be making the difference.

  5. #5
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Or this without the quotes. This works on an html tester.

    Code:
    <style>ul { display: block; list-style-type: disc; margin-top: 1em; margin-bottom: 1 em; margin-left: 0; margin-right: 0; padding-left: 0; }</style>
    
    <p>Dear xx (Dealer: xx),</p>
    <p>This email is in regards to a parts return for:</p>
    <p><b>Part Number(s)</b>:<br>xxxxx</p>
    <p>Please follow the attached instructions for your return.</p>
    <p>In order for your claim to be processed, please be sure to:</p>
    <p><ul><li>Print this email and return it with your shipment.</li><b>OR</b><br><li>Include your Dealer Number, Serial Number and Claim Number with your shipment.</li></ul></p>
    <p>***** For <b><u>Canadian</u></b> shipments, write your Dealer Number and Claim Number on the <b><u>OUTSIDE</u></b> or the container.</p>

  6. #6
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Code:
    Set cdomsg = CreateObject("CDO.message")
    
        With cdomsg.Configuration.Fields
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" .Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 587 .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xx@xx.com" .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xx" .Update
    End With htmlmsg = "<style>ul { display: block; list-style-type: disc; margin-top: 1em; margin-bottom: 1 em; margin-left: 0; margin-right: 0; padding-left: 0; }</style>" _
    & "<p><b>Part Number(s)</b>:<br>xx</p>" _ & "<p>Please follow the attached instructions for your return.</p>" _ & "<p>In order for your claim to be processed, please be sure to:</p>" _ & "<p><ul><li>Print this email and return it with your shipment.</li><b>OR</b><br><li>Include your Dealer Number, Serial Number and Claim Number with your shipment.</li></ul></p>" _ & "<p>***** For <b><u>Canadian</u></b> shipments, write your Dealer Number and Claim Number on the <b><u>OUTSIDE</u></b> of the container.</p>" _
    subj = "Test" With cdomsg
    .To = "xx@xx.com" .From = "xx@xx.com" .Subject = subj .HTMLBody = htmlmsg Set fso = New FileSystemObject Set srcfolder = fso.GetFolder("C:hello") If srcfolder.Files.Count > 0 Then
    For Each fsfile In srcfolder.Files
    If InStr(1, fsfile.Name, "Thumbs") = 0 Then Set ibp = .addattachment(fsfile.Path)
    Next
    Else
    GoTo attacherror
    End If Set fso = Nothing Set srcfolder = Nothing .Send
    End With

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    When I test this code with a html tester what I get everything aligned to the left hand side, which is what you wanted, at least I thought so, in your original post.

  8. #8
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Exactly, adjusting the margin-left property moves it as I desire. However, when I'm sending this email, it comes up on the other end as still indented. It's as if the style CSS is not being recognized.

  9. #9
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    So I have never attempted sending email with a third party product, in this case gmail. I've modified your code for my testing and I'd like you to tell me if I have correctly identified the places I must insert actual values to have this code work on my end.

    If you are actually using gmail this appears to be an error in how it is interpreting your HTML code.

    Just to be clear, you want to see the actual bullet marks, the little round dots, but you do not want it to be indented?
    I think the padding-left setting may be responsible for the left indent, not the margin setting.


    Code:
    Dim cdomsg
    Dim htmlmsg As String
    Dim subj As String
    
    Set cdomsg = CreateObject("CDO.message")
    
    With cdomsg.Configuration.Fields
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
    .Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 587
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xx@xx.com" '<-insert my gmail address
    .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xx"        '<-insert my gmail password
    .Update
    End With
    
    htmlmsg = "<style>ul { display: block; list-style-type: disc; margin-top: 1em; margin-bottom: 1 em; margin-left: 0; margin-right: 0; padding-left: 0; }</style>" _
    & "<p><b>Part Number(s)</b>:<br>xx</p>" _
    & "<p>Please follow the attached instructions for your return.</p>" _
    & "<p>In order for your claim to be processed, please be sure to:</p>" _
    & "<p><ul><li>Print this email and return it with your shipment.</li><b>OR</b><br><li>Include your Dealer Number, Serial Number and Claim Number with your shipment.</li></ul></p>" _
    & "<p>***** For <b><u>Canadian</u></b> shipments, write your Dealer Number and Claim Number on the <b><u>OUTSIDE</u></b> of the container.</p>" _
    
    subj = "Test"
    
    With cdomsg
    .To = "xx@xx.com"       '<-Insert my gmail address
    .From = "xx@xx.com"     '<-Insert my gmail address
    .Subject = subj
    .HTMLBody = htmlmsg
    .Send
    End With

  10. #10
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Yes, changing those 4 fields will allow it to send.

  11. #11
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I've just tested it and the only thing this code does not do is put in the bullet points (the actual little circles). Otherwise everything is aligned to the left as you initially stated you wanted. In order to get the bullets to appear I had to increase the left margin which indented the whole thing so it appears you can't have one without the other, either bullets and the indent or no bullets and no indent.

  12. #12
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Ya, playing with the margin will allow for the bullets to be seen. I am having a hard time understanding why it refuses to format the margins for me.

  13. #13
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Using the exact code you pasted...

    Click image for larger version. 

Name:	Indent Error 2.png 
Views:	9 
Size:	14.5 KB 
ID:	19257

  14. #14
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Looks like the issue is not just my own...

    http://stackoverflow.com/questions/1...-css-in-emails

    Still am yet to find out if you can adjust the margin using an inline <ul> statement rather than a CSS statement.

  15. #15
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I am not sure what to say, it may be an issue with gmail settings because when I ran it with a margin-left = 0 and a padding-left = 0 everything was left aligned but the bullet marks did not appear. This may possibly also be an artifact of the list-style-type as well. I wish I could help you more but it's odd that it works for me but not for you.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Send email using CDO, get email addresses from table
    By marvinac1 in forum Programming
    Replies: 3
    Last Post: 12-22-2014, 12:54 PM
  2. Replies: 5
    Last Post: 05-07-2014, 09:25 AM
  3. Export html to body of email issue
    By mmart33 in forum Reports
    Replies: 3
    Last Post: 02-28-2013, 03:16 PM
  4. HTML issue when using Word as email editor
    By dshillington in forum Programming
    Replies: 3
    Last Post: 02-14-2012, 03:28 PM
  5. Replies: 4
    Last Post: 04-13-2011, 10:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums