Skip to main content

I have several Server Mail Events and have edited code to manage desired date format as well as the addition of "objMsg.BodyFormat = Web.Mail.MailFormat.Html" to provide better-than-plain-text notifications. A sample of one event appears below. To work around my own inability to create a table within this code, I have added html tags to text surrounding fields as I cannot seem to format the actual fields. Is there a handy-dandy way to place my desired text within a table, or are there other options that would permit me to align this text in another manner? Thanks very much for reading. Happy Friday.

Sub Main(Byval K2 as ServerEventContext)
SMTPFunction(K2)
End sub
Function SMTPFunction(ByVal K2 As ServerEventContext)
Dim objMsg As New System.Web.Mail.MailMessage()
Dim objAttachment As System.Web.Mail.MailAttachment
Dim objSender As System.Web.Mail.SmtpMail
Dim strFrom as String
Dim strEmail As String
Dim strSubject As String
Dim strBody As String
Dim bozo, bozo1, bozo2 As DateTime
objSender.SmtpServer = SourceCode.K2Utilities.GeneralMod.GetDefaultSMTPServer()
strFrom = K2.ProcessInstance.Originator.Email
strEmail = "newinfo1@fowlerwhite.com"
If IsNothing(strEmail) OrElse strEmail.Trim().Length = 0 Then
Throw New System.Exception("No Email Address was supplied, please rectify and try again.")
End If
strSubject = K2.ProcessInstance.Folio
strBody = strBody & "Please be advised that on "
bozo = DateTime.Parse(SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:HR1startDate"))
strBody = strBody & bozo.ToLongDateString()
strBody = strBody & "
, The company will welcome the following individual:<br><br>"
strBody = strBody & System.Environment.NewLine
strBody = strBody & System.Environment.NewLine
strBody = strBody & "<blockquote>Name: &nbsp &nbsp &nbsp"
strBody = strBody & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:HR1firstName")
strBody = strBody & " "
strBody = strBody & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:HR1middleName")
strBody = strBody & " "
strBody = strBody & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:HR1lastName")
strBody = strBody & System.Environment.NewLine
strBody = strBody & "<br><br>
Title: &nbsp &nbsp &nbsp"
strBody = strBody & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:HR1employeeTitle")
strBody = strBody & System.Environment.NewLine
strBody = strBody & "<br><br>
Practice Group/Department: &nbsp &nbsp &nbsp"
strBody = strBody & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:HR1legal/my:HR1legalPracticeGroup")
strBody = strBody & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:HR1administrative/my:HR1administrativeDepartment")
strBody = strBody & System.Environment.NewLine
strBody = strBody & "<br><br>
Office: &nbsp &nbsp &nbsp"
strBody = strBody & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:HR1cityLocation")
strBody = strBody & System.Environment.NewLine
strBody = strBody & "<br><br>
Supervisor: &nbsp &nbsp &nbsp"
strBody = strBody & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:HR1Supervisor")
strBody = strBody & System.Environment.NewLine
strBody = strBody & "<br><br>
Secretary: &nbsp &nbsp &nbsp"
strBody = strBody & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:HR1Secretary")
strBody = strBody & System.Environment.NewLine
'strBody = strBody & "Orientation Date: "
'bozo1 = DateTime.Parse(SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:HR1orientationDate"))
'strBody = strBody & bozo1.ToLongDateString()
'strBody = strBody & System.Environment.NewLine
'strBody = strBody & System.Environment.NewLine
'strBody = strBody & "Expiration Date: "
'bozo2 = DateTime.Parse(SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:Expiration/my:HR1expDate"))
'strBody = strBody & bozo2.ToLongDateString()
objMsg.From = strFrom
objMsg.To = strEmail
objMsg.Subject = strSubject
objMsg.Body = strBody
objMsg.BodyFormat = Web.Mail.MailFormat.Html
objSender.Send(objMsg)
End Function

Yes, I am posting my own reply. I was missing proper syntax and should have entered code as excerpted below in order to properly create a table (please note the use of single as well as double quotes). I hope this helps any subsequent readers. Thanks. Happy Thursday.

strBody = strBody & "<table width='600' cellspacing='15' cellpadding='10'><tr><td align='right'>" & "Name:</td>" 
strBody = strBody & "<td><b>" & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:HR1firstName")
strBody = strBody & " "
strBody = strBody & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:HR1middleName")
strBody = strBody & " "
strBody = strBody & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:HR/my:HR1lastName") & "</b></td>"

Reply