Click here to Skip to main content
15,917,062 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: VB6 Extend maximum height of PictureBox Pin
Luc Pattyn3-Apr-10 5:01
sitebuilderLuc Pattyn3-Apr-10 5:01 
GeneralRe: VB6 Extend maximum height of PictureBox Pin
Bob Hiller3-Apr-10 5:31
Bob Hiller3-Apr-10 5:31 
GeneralRe: VB6 Extend maximum height of PictureBox Pin
Dave Kreskowiak3-Apr-10 5:52
mveDave Kreskowiak3-Apr-10 5:52 
Generalwinmm Pin
FlavioAR2-Apr-10 12:26
FlavioAR2-Apr-10 12:26 
GeneralRe: winmm - cross post Pin
Mycroft Holmes2-Apr-10 23:30
professionalMycroft Holmes2-Apr-10 23:30 
GeneralRe: winmm - cross post Pin
FlavioAR4-Apr-10 4:09
FlavioAR4-Apr-10 4:09 
GeneralRe: winmm - cross post Pin
riced4-Apr-10 4:50
riced4-Apr-10 4:50 
QuestionFormatting Text with VB [modified] Pin
lodogg1-Apr-10 17:26
lodogg1-Apr-10 17:26 
I'm by no means an expert but I would like to format the following text that I'm pulling from a MySQL database.

'From C:\e-mail\daily-totals.csv
"ReceivedAt","External","Hit_Count","Port" "2010-03-31 00:28:56","92.47.196.147","868","445" "2010-03-31 09:27:29","98.104.149.153","12","135" "2010-03-31 10:08:56","87.237.140.163","12","5900" "2010-03-31 02:49:33","221.195.73.86","12","8000" "2010-03-31 04:22:26","59.53.88.70","8","2967


I have a bash script running a select statement to pull syslog data from a mysql database but I would like to format it in HTML or make it e-mail friendlySmile | :) I'm using the following base code from a Microsoft link to e-mail a daily list of denies from a .csv file.

'--------------------------------------------------------------------
'
' Mailout using CDONTS.NewMail
'
'--------------------------------------------------------------------

' Declare all variables.
Option Explicit
Dim objSendMail
Dim strTo, strFrom
Dim strSubject, strBody

' Mail constants (some are for reference).
Const CdoBodyFormatHTML = 0 ' Body property is HTML
Const CdoBodyFormatText = 1 ' Body property is plain text (default)
Const CdoMailFormatMime = 0 ' NewMail object is in MIME format
Const CdoMailFormatText = 1 ' NewMail object is plain text (default)
Const CdoLow    = 0         ' Low importance
Const CdoNormal = 1         ' Normal importance (default)
Const CdoHigh   = 2         ' High importance

strFrom    = "MySQL@test.com"  ' Change to your e-mail address.
strTo      = "test@gmail.com"  ' Change to the recipient address.
strSubject = "Total Report"          ' Change to your subject.

' This line calls the ReadFile() function to read the page contents.
strBody = ReadFile("C:\e-mail\daily-totals.csv")

' This line calls the MakePage() function to format the page as HTML.
strBody = MakePage(strSubject,strBody)

' The following section creates the mail object and sends the mail.
Set objSendMail = CreateObject("CDONTS.NewMail")
	objSendMail.From    = strFrom
	objSendMail.To      = strTo
	objSendMail.Subject = strSubject & " (" & Date() & ")"
	objSendMail.Body    = strBody

	objSendMail.BodyFormat = CdoBodyFormatHTML
	objSendMail.MailFormat = CdoMailFormatMime
	objSendMail.Importance = CdoNormal

	objSendMail.Send
Set objSendMail = Nothing

' This function returns a properly formatted HTML page.
Function MakePage(txtSubject, txtBody)
	Dim txtTemp
	txtTemp = "<HTML>" & vbCrLf
	txtTemp = txtTemp & "<HEAD><TITLE>"
	txtTemp = txtTemp & txtSubject
	txtTemp = txtTemp & "</TITLE></HEAD>" & vbCrLf
	txtTemp = txtTemp & "<BODY>" & vbCrLf
	txtTemp = txtTemp & "<H2>" & txtSubject & "</H2>" & vbCrLf
	txtTemp = txtTemp & txtBody & vbCrLf
	txtTemp = txtTemp & "</BODY>" & vbCrLf
	txtTemp = txtTemp & "</HTML>"
	MakePage = txtTemp
End Function

' This function opens a file and returns the contents of the file.
Function ReadFile(txtFile)
	Dim txtTemp, objFS, objFL
	Set objFS = CreateObject("Scripting.FileSystemObject")
	Set objFL = objFS.OpenTextFile(txtFile)
	Do While Not objFL.AtEndOfStream
		txtTemp = txtTemp & objFL.ReadLine
		txtTemp = txtTemp & vbCrLf
	Loop	
	objFL.Close
	Set objFS = Nothing
	ReadFile = txtTemp
End Function


Is there a way to alter the strbody during the "Function ReadFile(txtFile)" command to alter the .csv file to something that would look a little more pretty inside of an e-mail?

Any help would be much appreciated....

If anyone would like to know how I'm getting Cisco Syslog data into a MySQL database I would be willing to enlighten you. I thought is was a somewhat cool process. I would rather take the Syslog data and write it to a MS SQL database if anyone has any idea's or links.

-lo
modified on Friday, April 2, 2010 12:08 AM

AnswerRe: Formatting Text with VB Pin
Luc Pattyn1-Apr-10 17:49
sitebuilderLuc Pattyn1-Apr-10 17:49 
GeneralRe: Formatting Text with VB Pin
lodogg1-Apr-10 18:15
lodogg1-Apr-10 18:15 
GeneralRe: Formatting Text with VB Pin
Luc Pattyn1-Apr-10 18:42
sitebuilderLuc Pattyn1-Apr-10 18:42 
GeneralRe: Formatting Text with VB Pin
lodogg2-Apr-10 8:35
lodogg2-Apr-10 8:35 
GeneralRe: Formatting Text with VB Pin
Luc Pattyn2-Apr-10 15:31
sitebuilderLuc Pattyn2-Apr-10 15:31 
GeneralRe: Formatting Text with VB Pin
Dalek Dave2-Apr-10 15:39
professionalDalek Dave2-Apr-10 15:39 
GeneralRe: Formatting Text with VB Pin
Luc Pattyn2-Apr-10 15:50
sitebuilderLuc Pattyn2-Apr-10 15:50 
GeneralRe: Formatting Text with VB Pin
Dalek Dave2-Apr-10 15:58
professionalDalek Dave2-Apr-10 15:58 
GeneralRe: Formatting Text with VB Pin
Luc Pattyn2-Apr-10 16:20
sitebuilderLuc Pattyn2-Apr-10 16:20 
GeneralRe: Formatting Text with VB Pin
lodogg2-Apr-10 18:06
lodogg2-Apr-10 18:06 
GeneralRe: Formatting Text with VB Pin
lodogg2-Apr-10 18:04
lodogg2-Apr-10 18:04 
GeneralRe: Formatting Text with VB Pin
Luc Pattyn2-Apr-10 18:23
sitebuilderLuc Pattyn2-Apr-10 18:23 
QuestionPipes and Files - making it work Pin
LurkingGryphon1-Apr-10 11:09
LurkingGryphon1-Apr-10 11:09 
AnswerRe: Pipes and Files - making it work Pin
Mycroft Holmes2-Apr-10 23:41
professionalMycroft Holmes2-Apr-10 23:41 
GeneralRe: Pipes and Files - making it work Pin
LurkingGryphon6-Apr-10 3:41
LurkingGryphon6-Apr-10 3:41 
GeneralRe: Pipes and Files - making it work Pin
Mycroft Holmes6-Apr-10 11:52
professionalMycroft Holmes6-Apr-10 11:52 
AnswerRe: Pipes and Files - making it work Pin
Gideon Engelberth3-Apr-10 6:09
Gideon Engelberth3-Apr-10 6:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.