Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Attachment
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
01396455
Message ID:
01396466
Vues:
153
This message has been marked as the solution to the initial question of the thread.
>an age old problem. has anyone found a way to append an attacment to an email
>&attachment does not work
>
>em= "mailto:someone@somewhere.ca?cc=someone%20else&bcc=other@somewhere.ca&subject=Documents&body=Open attachment."
>oIE = CreateObject ("internetexplorer.application")
>oIE.NAVIGATE ("&em")
>oIE.VISIBLE = .F.

I belive the following was written by Craig Boyd, but his site is down at the moment. Depending which program (between Outlook or Outlook Express) is your default e-mail program, this should open up an e-mail message with the attachement ready to go. Just change your default program as needed.
Dimension aryAttach(1) && Add as many elements (attachments) as you like
Local lcFrom, lcTo, lcSubject, lcBody, lnCount, lcCC, lcBCC, lcUserName, lcPassword, llEmailStatus, lcErrorHandlerWas
***** Replace the following with real values to run this example********
aryAttach(1) = "C:\done.txt" && File to attach, add more if needed
lcFrom = "me@somewhere.net"
lcTo = "you@somewhere.net"
lcCC = "mv@met.com"
lcBCC = "mv2@met.com"
lcUserName = "" && Only if required by default smtp server
lcPassword = "" && Only if required by default smtp server
*************************************************************
lcSubject = "VFP Email Via MAPI"
lcBody = "MAPI seems to work pretty good."
lcErrorHandlerWas = On("ERROR")
Wait Window " One Moment... Email is being generated and sent " Nowait

llEmailStatus = SendViaMAPI(lcFrom, lcTo, lcSubject, lcBody, @aryAttach, lcCC, lcBCC, lcUserName, lcPassword)
On Error &lcErrorHandlerWas
Wait Clear
If llEmailStatus
	Messagebox("Your message to " + lcTo + " has been sent.",64,"EMAIL SENT SUCCESSFULLY VIA MAPI")
Else
	Messagebox("Your message to " + lcTo + " was not sent.",64,"EMAIL PROBLEM WITH MAPI")
Endif

**********************************************************************
Function SendViaMAPI(tcFrom, tcTo, tcSubject, tcBody, taFiles, tcCC, tcBCC, tcUserName, tcPassword)
**********************************************************************
#Define Primary 1
#Define CARBON_COPY 2
#Define BLIND_CARBON_COPY 3
Local loSession, loMessages
On Error Return(.F.)
loSession = Createobject("MSMAPI.MAPISession")
If Type('tcUserName') = 'C'
	loSession.UserName = tcUserName
Endif
If Type('tcPassword') = 'C'
	loSession.Password = tcPassword
Endif
loSession.Signon()
If (loSession.SessionID > 0)
	loMessages = Createobject( "MSMAPI.MAPIMessages" )
	loMessages.SessionID = loSession.SessionID
Endif
With loMessages
	.Compose()
	.RecipDisplayName = tcTo
	.RecipType = Primary
	.ResolveName()
	If Type("tcCC") = "C" And !Empty(tcCC)
		.RecipIndex = .RecipCount
		.RecipDisplayName = tcCC
		.RecipType = CARBON_COPY
		.ResolveName()
	Endif
	If Type("tcBCC") = "C" And !Empty(tcBCC)
		.RecipIndex = .RecipCount
		.RecipDisplayName = tcBCC
		.RecipType = BLIND_CARBON_COPY
		.ResolveName()
	Endif
	If Type('taFiles',1) = "A"
		For lnCountAttachments = 1 To Alen(taFiles)
			.AttachmentIndex = .AttachmentCount
			.AttachmentPathName = taFiles(lnCountAttachments)
		Endfor
	Endif
	.MsgSubject = tcSubject
	.MsgNoteText = tcBody
	.Send(.T.)
Endwith
loSession.Signoff()
Store .Null. To loSession, loMessages
Release loSession, loMessages
Return .T.
Endfunc
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform