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]
# 1
Glenna:

You say you don't get line breakers. Are you actually sending HTML code? (i.e. < br >)

Try this simplified sample. Does it work for you?:

#DEFINE olFolderInbox 6
#DEFINE
olFolderOutbox 4
#DEFINE
olMailItem 0
#DEFINE
olRecipient 4
#DEFINE
olRecipients 17
#DEFINE IMPORTANCENORMAL 1
loApp=CreateObject("Outlook.Application")
loNamespace = loApp.GetNamespace("MAPI")
loFolder = loNamespace.GetDefaultFolder(olFolderInbox)
loEMailItem = loFolder.Items.
Add(olMailItem)
loEmailItem.Subject = "Subject here"
loEmailItem.Importance = IMPORTANCENORMAL

loEmailItem.HTMLBody = [<html><font face = "Arial">];
+ [<font size = 2> <font color = 0>This is <b>bold</b>, this is <font color="red">red</font><br>Line2<br></font></html>]
loemailitem.
Display()
*loEmailItem.Send
*loApp.Quit()
release loApp, loEmailItem

AlexFeldstein at 2007-9-8 > top of Msdn Tech,Visual FoxPro,Visual FoxPro General...
# 2
As Alex noted you need < br > tag instead of CRLF.

lcNotes = strtran(chrtran(This.Parent.EdtNotes.Value, ;
chr(10),''),chr(13), '<br>')
loEmailItem.HTMLBody = [<html><font face = ]+ Slcrm.cbodyfont+[>];
+ [<font size = ] + lnSize + [> <font color = ] + lcColor + [>] + m.lcNotes;
+ [</font></html>]

CetinBasoz at 2007-9-8 > top of Msdn Tech,Visual FoxPro,Visual FoxPro General...
# 3
I had the same problem before but was already fixed. My next problem is if there is a way where I cound emails without opening any email clients.
VFUSER at 2007-9-8 > top of Msdn Tech,Visual FoxPro,Visual FoxPro General...
# 4

but how can send data from dbf or form. please write examle

thanks

khubaib at 2007-9-8 > top of Msdn Tech,Visual FoxPro,Visual FoxPro General...
# 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.

AndrewMacNeill at 2007-9-8 > top of Msdn Tech,Visual FoxPro,Visual FoxPro General...
# 6

Besides attachments, as Andrew showed, you could put data in the body of the email, either as text or as HTML if that is accepted by the recipient.

Just traverse the table (SCAN..ENDSCAN) and build the body using TEXT..ENDTEXT.

See examples:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_foxhelp9/html/2cb5be90-2563-455d-bd3c-8a243aff5211.asp?frame=true

AlexFeldstein at 2007-9-8 > top of Msdn Tech,Visual FoxPro,Visual FoxPro General...
# 7

I hope youb can shed some light on my problem.

When I try to run loApp=CreateObject("Outlook.Application") I get the error module not found. I have truied re-installing outlook, but still get the dame error. I have regsvr32.exe cdo.dll as someone else suggested. Ny help would be appreciated.

Don

Don_Ram at 2007-9-8 > top of Msdn Tech,Visual FoxPro,Visual FoxPro General...
# 8
You could FTP to emailserver.
CetinBasoz at 2007-9-8 > top of Msdn Tech,Visual FoxPro,Visual FoxPro General...
# 9
>>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.

DaveM. at 2007-9-8 > top of Msdn Tech,Visual FoxPro,Visual FoxPro General...
# 10

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.

hoabinh at 2007-9-8 > top of Msdn Tech,Visual FoxPro,Visual FoxPro General...
# 11

I tried the code but I got error that "The server rejects sender address. Authentication is required".

I wonder why I don't need to supply my SMTP user name and password.

Thanks.

Joe.

JoeAu at 2007-9-8 > top of Msdn Tech,Visual FoxPro,Visual FoxPro General...