[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

How to send an e-mail in VB6 with HTML

Hey everyone!
I am looking to make my program e-mail a daily report to a few pre-set e-mail accounts.
I'd like to be able to use html in the e-mail so the end result looks like what EE sends out when someone posts a comment to your question.
I would like it to match the GUI of my program.
I would like it to be able to support "Server requires auth to send mail" feature because My servers require that.
0
JesNoFear
Asked:
JesNoFear
  • 4
  • 4
  • 2
  • +1
3 Solutions
 
edwardiiiCommented:
Hi, JesNoFear.

One way to incorporate HTML coding in your emails (if you're using Outlook, add Outlook object library to project
references):

    Dim outApp As Outlook.Application
    Dim olMail As MailItem
    Dim strFontControlBody, strSubject, strTemplate, strTo As String
    Set outApp = New Outlook.Application
    Set olMail = outApp.CreateItem(olMailItem)
       
    strFontControlBody = "<font face = MS Sans Serif size=3>" & "Your body text here" & "</font>"
    strSubject = "Your subject here"
    strTo = "Your email recipients here"
       
    With olMail
        .To = strTo
        .Subject = strSubject
        .HTMLBody = strFontControlBody
        '.Attachments.Add _
        'source:="C:\Howdy.jpg"
        .Display
    End With
0
 
Shiju SasidharanCommented:
hi

this seems good

http://www.paulsadowski.com/WSH/cdo.htm

;-)
Shiju
0
 
JesNoFearAuthor Commented:
The content you insert into 'strFontControlBody' is html coding corrent?
are there returns needed between lines? '& chr(13) & chr(10) &'
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
PaulHewsCommented:
This component supports HTML mail.  It is very reliable and free.
http://www.freevbcode.com/ShowCode.Asp?ID=109

>I would like it to be able to support "Server requires auth to send mail" feature because My servers require that.

Yes it supports this as well.  Let me know if you need help with the code.
0
 
JesNoFearAuthor Commented:
I keep getting a (The "SendUsing" configuration value is invalid.) messange when i try to use Shiju's solution....
0
 
JesNoFearAuthor Commented:
never mind, it was my error
0
 
Shiju SasidharanCommented:
can u please place the code  u tried ?
0
 
Shiju SasidharanCommented:
try using this value

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1

0
 
JesNoFearAuthor Commented:
i hadn't added the schemas.ms...... into it because i though it was only comments....
0
 
Shiju SasidharanCommented:
well, u got it working ;-)
0
 
edwardiiiCommented:
Hello, again.

Yes, the strFontControlBody contains HTML.  It was built from the contents of a Textbox; I had to replace all occurrences
of "vbNewLine" with "<br>" because in my Outlook emails, Outlook ignored the vbNewline code:

     strTxtAllConvert  = Replace(txtAll.Text, vbNewLine, "<br>")
     strFontControlBody = "<font face = MS Sans Serif size=3>" & strTxtAllConvert & "</font>"

Thank you for the points;)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 4
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now