> -----Original Message----- > From: profoxtech-boun...@leafe.com [mailto:profoxtech-boun...@leafe.com] > On Behalf Of Paul McNett > Sent: Monday, August 22, 2011 11:16 AM > To: profoxt...@leafe.com > Subject: Re: Sending E-mail from VFP >
My code for doing formatted HTML email is below (written for MS Access but you can translate it I'm sure): cEmailList = objRS.Fields("Email_List") cFrom_Email = objRS.Fields("from_email") cSMTP = objRS.Fields("smtp_server") cSeperatorString = cTab & objRS.Fields("data_seperator") & cTab 'setup for sending email as HTML format cMsgString = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'><HTML>" cMsgString = cMsgString & "<HEAD><META HTTP-EQUIV='CONTENT-TYPE' CONTENT='text/html; charset=windows-1252'><TITLE></TITLE>" cMsgString = cMsgString & "<META NAME='GENERATOR' CONTENT='OpenOffice.org 3.2 (Win32)'><META NAME='CREATED'" cMsgString = cMsgString & "CONTENT='20100407;10503400'><META NAME='CHANGED' CONTENT='20100407;11043400'></HEAD>" cMsgString = cMsgString & "<BODY LANG='en-US' DIR='LTR'>" cMsgString = cMsgString & "<TABLE WIDTH=50% BORDER=1 CELLPADDING=1 CELLSPACING=1>" Dim cRowBegin, cRowEnd, cCellBegin, cCellEnd As String cRowBegin = "<TR>" cRowEnd = "</TR>" cCellBegin = "<TD WIDTH=25% VALIGN=TOP><FONT FACE='verdana'>" cCellEnd = "</FONT></TD>" 'build the message body with each field as one row/line cMsgString = cMsgString & cRowBegin & cCellBegin & "Appointment Type" & cCellEnd & cCellBegin & Me.Appointment_Type.Value & cCellEnd & cEndLineString cMsgString = cMsgString & cRowBegin & cCellBegin & "Has Current Appointment" & cCellEnd & cCellBegin & Me.Has_Current_Appointment.Value & cCellEnd & cEndLineString cMsgString = cMsgString & cRowBegin & cCellBegin & "Date Of Service" & cCellEnd & cCellBegin & Me.Date_Of_Service.Value & cCellEnd & cEndLineString //etc etc etc.... 'done writing the message body in HTML format cMsgString = cMsgString & "</TABLE></BODY></HTML>" 'if not in there, stuff it into a table so we can verify if this notification has been sent already If objRSSent.EOF Then Dim cUpdateString As String cUpdateString = "INSERT INTO EmailsSent ([Date_Of_Service], [Patient_Last_Name], [Patient_First_Name], [Date_Email_Sent]) values (""" & Me.Date_Of_Service.Value & """, """ & Me.Patient_Last_Name.Value & """, """ & Me.Patient_First_Name.Value & """, """ & Now() & """)" DoCmd.SetWarnings False DoCmd.RunSQL cUpdateString DoCmd.SetWarnings True End If 'this code stolen from: http://classicasp.aspfaq.com/email/how-do-i-send-e-mail-with-cdo.html sch = "http://schemas.microsoft.com/cdo/configuration/" Set cdoConfig = CreateObject("CDO.Configuration") With cdoConfig.Fields .Item(sch & "sendusing") = 2 ' cdoSendUsingPort .Item(sch & "smtpserver") = cSMTP ' .Item(sch & "smtpserver") = "xxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxx" .Update End With Set cdoMessage = CreateObject("CDO.Message") With cdoMessage Set .Configuration = cdoConfig .From = cFrom_Email .To = cEmailList .Subject = "Patient Pre-Registration Entry for: " & Me.Patient_Last_Name.Value & ", " & Me.Patient_First_Name.Value & " " & Me.Patient_Middle_Name.Value & " -- Date of Service: " & Me.Date_Of_Service.Value //can toggle HTML or regular: .HTMLBody = cMsgString ' .TextBody = cMsgString .Send MsgBox "Message Sent for: " & Me.Patient_Last_Name.Value & ", " & Me.Patient_First_Name.Value & " " & Me.Patient_Middle_Name.Value End With Set cdoMessage = Nothing Set cdoConfig = Nothing End If</BODY></HTML><P><hr size=1></P><P>Disclaimer: This electronic message may contain information that is Proprietary, Confidential, or legally privileged or protected. It is intended only for the use of the individual(s) and entity named in the message. If you are not an intended recipient of this message, please notify the sender immediately and delete the material from your computer. Do not deliver, distribute or copy this message and do not disclose its contents or take any action in reliance on the information it contains.</P></BODY></HTML> _______________________________________________ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/69f310c05dd83c48a84ba3769ce1ecf805892...@tntriexevs02.triadhospitals.net ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.