sending email from VFP through MS Outlook
We have the following code for sending email to Outlook.
The email gets sent, but the font size is always 36 px or 36 pt (we tried both).
None of the <cr><lf> show up. The email is one big paragraph.
Can anyone help?
Here is the code:
LOCAL loApp, loEmailItem, cHex
lnsize = '"' + str(gaPointsize(Slcrm.nbodysize),2,0)+ '"'
cHex = ''
nDec = Slcrm.nColor
nPower = 8
DO WHILE nPower > 0
cHex = cHex + hexdigit(INT(nDec/16^(nPower-1)))
nDec = MOD(nDec,16^(nPower-1))
nPower = nPower - 1
ENDDO
lcColor= '#' + RIGHT(cHex,6)
* lcColor = '#' + strtran(Transform(GetColor(),'@0'),'0x00','')
loApp = CREATEOBJECT("Outlook.application")
loEmailItem = loApp.CreateItem(0) && MAILITEM
loEmailItem.Recipients.Add(ThisForm.cURL) &&Uses the Recipients colleection
loEmailItem.Subject = This.Parent.Txtsubject.Value
loEmailItem.Importance = 1 && IMPORTANCENORMAL
loEmailItem.HTMLBody = [<html><font face = ]+ Slcrm.cbodyfont+[>];
+ [<font size = ] + lnSize + [> <font color = ] + lcColor + [>] + This.Parent.EdtNotes.Value;
+ [</font></html>]
loEmailItem.Send
release loApp, loEmailItem
[1295 byte] By [
glenna] at [2008-2-5]
Khubaib,
How do you mean send data from dbf or form?
If you are referring to attachments, use the Attachments property.
loItem.Subject = "my Mail"
loItem.Attachments.Add("C:\myfile.dbf")
Keep in mind that if the user has virus scanning or security settings , the file may be stripped before going out but that should be all that is required.
>>if there is a way where I cound emails without opening any email clients.
You can use CDO, IMO I find outlook automation the most foolproof.
loConfig = CREATEOBJECT('CDO.Configuration')
loCdoMessage = CREATEOBJECT("CDO.Message")
loCdoMessage.Configuration = loConfig
loCdoMessage.From = "info@wantit.nl"
loCdoMessage.To = "info@microsoft.com"
loCdoMessage.HtmlBody = "Body text"
loCdoMessage.Addattachment("c:\file.doc")
loConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
loConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "yoursmtpserver"
loConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
loConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
loConfig.Fields.Update
loCdoMessage.Send()
Dave M.
I use a text file with MIME structure to make a source for my email, and I copy it to "pickup folder", sending auto with IIS service. When I attach a text file by copy a detail of the text file to the attaching part of MIME structure, it working well.
But when I attach a non-text file as zip file, it makes error with the attach file (I also copy the detail of zip file by the fread() and fput() function.
Would you like to give me your help to attach a file as zip file? If I have to change the "source file" from text file to another type as binary file o html file....?
I also did it well with CDO, but I think sending mail with "pickup folder" through IIS with SMTP service is still simple and faster.
Thanks for your help.