Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to send mails with files attachment from vfp
Message
 
À
14/03/2009 17:09:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01344536
Message ID:
01388284
Vues:
59
>Hi Bill, I don't think I am going the right way about using your code. I put the code in a prg file and am trying to call it from a form. Can you please direct me step by step how to include this class and use it in a form. Appreciate you help.
>Cheers. Shafid

I just realized that what I posted attempts to set registry values that BLAT needs in order to function - specifically SMTP_SERVER (the SMTP server to send mail through), SMTP_PORT (normally 25), and Try (number of tries before BLAT assumes an error when sending). My code uses a registry class of mine to set those values. You can either use BLAT itself (the docs tell you how) or you can manually set those keys in HKEY_LOCAL_MACHINE\SOFTWARE\Public Domain\Blat. If you'd rather use my registry class, let me know and I'll dig that up for you.

Here's a function that provides an easy wrapper for the class..
function SendBlatmail

LPARAMETERS lcTo,lcCC,lcBCC,lcSubject,lcMessageString,lcMessageFile,lcAttachments,lcFrom

LOCAL llReturn

llReturn = .T.

IF EMPTY(lcTo) AND EMPTY(lcCC) AND EMPTY(lcBCC)
	&& nobody to send to!
	messagelog('SendBlatMail was called with no email TO addresses - Can NOT send mail!')
	RETURN .f.
endif

IF EMPTY(lcto)
	lcto = ''
ENDIF
IF EMPTY(lcCC)
	lcCC = ''
ENDIF
IF EMPTY(lcBCC)
	lcBCC = ''
ENDIF
IF EMPTY(lcSubject)
	lcSubject = ''
ENDIF
IF EMPTY(lcMessageString)
	lcMessageString = ''
ENDIF
IF EMPTY(lcMessageFile)
	lcMessageFile = ''
ENDIF
IF EMPTY(lcAttachments)
	lcAttachments = ''
ENDIF

oBlatMail=NEWOBJECT('sendblatmail','blatmail.prg')

IF VARTYPE(oBlatMail) <> 'O'
	llReturn = .f.
ENDIF

IF llReturn

	llReturn = oBlatMail.send(lcto,lccc,lcbcc,lcSubject,lcMessageString,lcMessageFile,IIF(!EMPTY(lcMessageString),.T.,.F.),lcAttachments,lcFrom)

ENDIF && llReturn

&& clean up, get out..

IF VARTYPE(oBlatMail) = 'O'
	RELEASE oBlatMail
ENDIF

RETURN llReturn
____________________________________

Don't Tread on Me

Overthrow the federal government NOW!
____________________________________
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform