1 Attachment(s)
Send HTML email with Text Boxes
Hi,
I want to make a send email function which display Text Boxes in the email content so that my receipents can fill in accordingly. However, besides the auto-generated Text Boxes, the sender also need to type-in some information before the mail is sent out. So once I click on the "EMAIL" button in my vb form, the Text Boxes and some information is auto-generated. The sender is able to see these info+TextBoxes before he/she clicks SEND to send the email out.
My Problem:
1) Initially i did it with CreateObjebct("Outlook.Application") to automate Microsoft Outlook application. It works by i construct the Text Boxes and info and put them into HTML tags. However the users only have Outlook Express but not Microsoft Outlook so this method is out.
2) I tried another method which I send Email With MAPI Components. However, I had been told that MAPI doesn't support HTML email
3) Now, i used vbSendMail.dll and SMTP server to send the email since it support the HTML. However, it displays the HTML tags and it is hard to read by users whose dont know about HTML since they need to type/add on information to the email content.
Any idea on what will be the best solution for this probem?
Re: Send HTML email with Text Boxes
vbSendMail probably isn't being used properly, because HTML e-mails need to send along MIME information otherwise it will be interpreted as a plaintext e-mail on the receiving end.
Can you post the code you're using?
Re: Send HTML email with Text Boxes
Code:
Private Sub cmdSend_Click()
lstStatus.Clear
Screen.MousePointer = vbHourglass
With poSendMail
.SMTPHostValidation = validate_none ' Optional, default = VALIDATE_HOST_DNS
'.EmailAddressValidation = VALIDATE_SYNTAX ' Optional, default = VALIDATE_SYNTAX
.EmailAddressValidation = validate_none
.Delimiter = ";" ' Optional, default = ";" (semicolon)
.SMTPHost = "smtp.bizmail.yahoo.com"
.From = txtFrom.Text ' Required the fist time, optional thereafter
.Recipient = txtTo.Text ' Required, separate multiple entries with delimiter character
.CcRecipient = txtCc ' Optional, separate multiple entries with delimiter character
.BccRecipient = txtBcc ' Optional, separate multiple entries with delimiter character
.ReplyToAddress = txtFrom.Text ' Optional, used when different than 'From' address
.Subject = txtSubject.Text ' Optional
.message = txtMsg.Text ' Optional
'.message = "<html><body><b>Hello There</b><img src=""smileyface.gif""> </body></html>"
.Attachment = Trim(txtAttach.Text) ' Optional, separate multiple entries with delimiter character
.AsHTML = bHtml ' Optional, default = FALSE, send mail as html or plain text
.ContentBase = "" ' Optional, default = Null String, reference base for embedded links
.EncodeType = MyEncodeType ' Optional, default = MIME_ENCODE
.Priority = etPriority ' Optional, default = PRIORITY_NORMAL
'.Receipt = bReceipt ' Optional, default = FALSE
.UseAuthentication = bAuthLogin ' Optional, default = FALSE
.UsePopAuthentication = bPopLogin ' Optional, default = FALSE
.UserName = txtUserName ' Optional, default = Null String
.Password = txtPassword ' Optional, default = Null String, value is NOT saved
.POP3Host = "pop.bizmail.yahoo.com"
.SMTPPort = 587 ' Optional, default = 25
.Send
End With
Screen.MousePointer = vbDefault
cmdSend.Enabled = True
End Sub
These are the code I refered to vbSendMail.dll.
Here, the txtMessage (which u saw a bunch of HTML codes) is what i retrieved from the parent of this email form.
PARENT:
Code:
HTML = HTML & "<html>"
HTML = HTML & "<head>"
HTML = HTML & "<title>HTMLMail</title>"
HTML = HTML & "</head>"
HTML = HTML & "<body bgcolor=""FFFFFF"">"
HTML = HTML & "<p><font size =""3"" face=""Verdana""><strong>"
HTML = HTML & "DEAR ALL,<br><br>Kindly review the spec base on the revision below. "
HTML = HTML & "Hopefully you will find time to review it.</strong></p>"
HTML = HTML & "<p><font size =""2"" face=""Verdana"">"
HTML = HTML & "DOCUMENT ID: " & ComboID.Text & "<br>"
HTML = HTML & "DOCUMENT NUMBER: " & documentnumber & "<br>"
HTML = HTML & "DOCUMENT TITLE: " & documenttitle & "<br>"
HTML = HTML & "REVISION: " & rev & "<br>"
HTML = HTML & "REVIEW DATES: " & "<br><br>"
HTML = HTML & "REV. HISTORY: <br><br><br><br>"
HTML = HTML & "REASON: " & ComboID.Text & "<br>"
HTML = HTML & "ECN NO: " & "<br>"
HTML = HTML & "ORIGINATOR: " & Originator & "<br>"
HTML = HTML & "ANALYST: " & "<br><br><br>"
HTML = HTML & "Please see attached Spec for your reference. You have <u>7 days</u> to review and approve the spec. Kindly reply to this email, fill-up the form then send it back to me."
HTML = HTML & "<br><br><br><br><br><br><br><br><br>"
HTML = HTML & "<font size=""3"" face=""Verdana""><b>" & title & "</b></font><br><br><br>"
'columns to be filled in
HTML = HTML & "<table border=""2"" cellpadding=""20"" width=""70%""><br><br>"
HTML = HTML & "Type only in the areas designated for data entry. Your reply will be automatically processed. Therefore, it is important that the form or the message is not altered in any other way. For more information about filling out this form, see the following:<br><br><br>"
Set rs = New ADODB.Recordset
rs.Open "SELECT masterperson.Name, masterperson.Department FROM masterperson INNER JOIN persontoint " & _
"ON masterperson.EmployeeNo=persontoint.EmployeeNo WHERE persontoint.Id='" & ComboID.Text & "'", db_connect, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
Do While Not rs.EOF
HTML = HTML & "<font size=""2"" face=""Verdana""><u>" & rs!Name & "</u></font>"
HTML = HTML & "<table border=""1"" width=""100%"">"
HTML = HTML & "<font size=""2"" face=""Verdana"">"
HTML = HTML & "<tr>"
HTML = HTML & "<td width=""30%"">" & rs!Department & " ACTUAL DATE</td>"
HTML = HTML & "<td width=""500px""></td>"
HTML = HTML & "</tr>"
HTML = HTML & "<tr>"
HTML = HTML & "<td width=""30%""></td>"
HTML = HTML & "<td width=""500px"">Type either a date, a time, or a combination of both in the following format: 1/13/2009</td>"
HTML = HTML & "</tr>"
HTML = HTML & "<tr>"
HTML = HTML & "<td width=""30%"">" & rs!Department & " COMMENT</td>"
HTML = HTML & "<td width=""500px""></td>"
HTML = HTML & "</tr>"
HTML = HTML & "<tr>"
HTML = HTML & "<td width=""30%""></td>"
HTML = HTML & "<td width=""500px"">Type any combination of numbers and letters up to 255 characters.</td>"
HTML = HTML & "</tr>"
HTML = HTML & "</font>"
HTML = HTML & "</table><br><br>"
rs.MoveNext
Loop
End If
HTML = HTML & "</table>"
HTML = HTML & "</body>"
HTML = HTML & "</html>"
I generate into HTML because I want the email to be displayed with text boxes and bold font. Although you saw messy HTML code inside txtMessage area, but when i click on SEND button to send the mail, I can see the neatly email with text boxes, information and tables when read from my mailbox
Re: Send HTML email with Text Boxes
a std text box will not display html, only the text, try using a webbrowser control, that can display html
Re: Send HTML email with Text Boxes
Hi westconn1,
Now I can display my email content under the WebBrowser control. However, I found out that there will be more user-friendly if the content under WebBrowser can be edited in the run-time. Is it possible?
Actually I am thinking of doing a feature similar as Microsoft Frontpage, which user can type in whatever they want in the design page, while the HTML code is auto-generated in the back-end.
Help me please.
Re: Send HTML email with Text Boxes
i made richtext box to compose /edit email then convert the rich text to html