|
-
Jan 23rd, 2007, 02:26 PM
#1
Thread Starter
Member
[RESOLVED] Using bullets in strings
I'm trying to get a program to take text input from a form and put it into an Outlook email. Part of the text in the email needs to be in bullets and I'm at a loss on how to do this.
Currently, I'm storing the text that will make up the body of the email in a string variable, so I thought the easiest way to include some bulleted lines would be to precede the particular line with the "Chr(??)" code for whatever number stood for a bullet. I tried looking up the character code for a bullet though and it doesn't seem to exist.
Does anyone have any suggestions?
Thanks!!
-
Jan 23rd, 2007, 02:38 PM
#2
Frenzied Member
Re: Using bullets in strings
I could be mistaken, but I believe that emails that are sent out that have color, images, bullet points ect.... are done in HTML format. So if you add html tags to your string variable that would get it to display correctly.
-
Jan 23rd, 2007, 02:48 PM
#3
Thread Starter
Member
Re: Using bullets in strings
Sorry - I'm a little unfamiliar with that... How do you add html tags to your string variables?
-
Jan 23rd, 2007, 04:08 PM
#4
Fanatic Member
Re: Using bullets in strings
String variables can take pretty much any typable character. So you could do this:
VB Code:
Dim EMailBody as string
EmailBody = "<ul><li>ListItem</li><li>NextListItem</li></ul>"
I know this probably needs some tweaking but I hope you get the idea. You may also be able to use the stringbuilder class to have more functionality available to you.
Oops forgot to end my quotes
D
Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP
Please Rate If I helped you. 
Please remember to mark threads as closed if your issue has been resolved.
Reserved Words in Access | Connection Strings
-
Jan 23rd, 2007, 05:32 PM
#5
Re: Using bullets in strings
Depends on the message type. If its rich text, then you would have to set the rich-text equivalent of whatever the bullet is. Rich text is just another markup type like HTML...
Check this link for format specifications. There is a "Bullets and Numbering" section that has information that could be useful.
RTF is more complex than HTML, so I would use that instead of RTF...
Last edited by gigemboy; Jan 23rd, 2007 at 05:39 PM.
-
Jan 24th, 2007, 08:51 AM
#6
Thread Starter
Member
Re: Using bullets in strings
 Originally Posted by dminder
VB Code:
Dim EMailBody as string
EmailBody = "<ul><li>ListItem</li><li>NextListItem</li></ul>"
I tried that but when it put it in the Outlook message, it was just this:
<ul><li>myString</li></ul>
-
Jan 24th, 2007, 09:19 AM
#7
Re: Using bullets in strings
that is because that is how outlook handles things if you simply paste the HTML string into a new mail message. Also make sure your new emails are not set to plain or rich text instead of HTML
What you should do is automate outlook to send the email from your VB app, so you don't have to manually copy/paste HTML into an outlook message. You can also specify the message type as HTML this way.
however if you simply want to just make HTML, and then copy/paste it into outlook, first save the HTML to a file, and open in in IE, copy/paste the IE page into outlook, and it will work as you were expecting.
-
Jan 24th, 2007, 09:27 AM
#8
Thread Starter
Member
Re: Using bullets in strings
I thought I had it set up for Outlook to send the email from the VB code...
VB Code:
Public Sub SendEmail()
Dim OLApp As New Microsoft.Office.Interop.Outlook.Application
Dim Msg As MailItem = OLApp.CreateItem(OlItemType.olMailItem)
Msg.BodyFormat = OlBodyFormat.olFormatHTML
Msg.Body = frmQA.Body
Msg.Send()
End Sub
Are you talking about something different?
-
Jan 24th, 2007, 09:35 AM
#9
Re: Using bullets in strings
no that is what I was talking about. Your post just sounded like you were copy/pasting from VB to outlook or something.
So you are saying when you run that code and the email is sent (to who I don't know because I don't see a to field specified) it shows up looking like just a string, and not like HTML markup?
-
Jan 24th, 2007, 09:48 AM
#10
Thread Starter
Member
Re: Using bullets in strings
I tried copying and pasting first, but went pack to automatic when that didn't work. Ok, here is my complete test code:
VB Code:
Public Sub SendEmail()
Dim OLApp As New Microsoft.Office.Interop.Outlook.Application
Dim Msg As MailItem = OLApp.CreateItem(OlItemType.olMailItem)
Msg.BodyFormat = OlBodyFormat.olFormatHTML
Dim test As String = "Testing"
Msg.Body = "<ul><li>test</li></ul>"
Msg.Send()
End Sub
And here is the email text I get:
<ul><li>test</li></ul>
Since it didn't read 'test' as a variable, I also tried this:
Msg.Body = "<ul><li>" & test & "</li></ul>"
but that just changed the email to say this:
<ul><li>Testing</li></ul>
-
Jan 24th, 2007, 09:56 AM
#11
Thread Starter
Member
Re: Using bullets in strings
I've stumbled across the answer!!!
Instead of
Msg.Body = "<ul><li>test</li></ul>"
it must be
Msg.HTMLBody = "<ul><li>test</li></ul>"
This did the trick. Thanks for all the help you guys!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|