Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sending Email - using MIME correctly?
Message
De
02/04/2006 12:22:19
 
 
À
31/03/2006 15:04:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Divers
Thread ID:
01109182
Message ID:
01109815
Vues:
111
>Hi Gregory,
>
> Okay, I got the code to run thru without error, but I do not get the mail I sent to myself. I tried two different email addresses, one inside the firewall, one outside. I have not gotten an undelverible message back, or the message that I sent. and the msgSource.txt file looks like what I get in my inbox, except the table code is in a different encode then what I sent with my code.
>
>Thanks for the help
>
>>Beth,
>>
>>(1) Below all the cdo constants, including the cdoXUnsent (maybe you can leave that line out, do not know)
>>
>>(2) re dbf: maybe the base64 encoding is not correct
>>
>>(3) I do send smtp mail, but with CDO. There's a bit more code you need - if you want it, let me know
>>
>>Good luck
>>
>< < snip > >
_____________________________________
hi Beth,

I'm confused

I did not say - and if I gave you that impression, sorry - that you would be able to send a file, saved with the code I provided

You have a problem with certain attachments.

I'm using that code to prepare a mail, save it as .eml, and then shellexecute it if the mail app of the user is Outlook Express
I only prepare the mail, the user can modify it and send it if he wants to

I do not know what the attachment problem is that you have, but I thought: If I can prepare a mail with attachments that way and Outlook Express accepts it, then Beth will be able to figure out what she is doing wrong


This is the code I use to send an smtpmail with CDO. I was too lazy to make the mail messages myself. I tried to use something that already existed

You may want to use this instead. Very simple and no problem with attachments - you'll have to change a couple of things

It even sends mail if the user has no mail configured (FromId = ["] + sys(0) + [" ])
The user needs internet access or a local mail server though

Hope it helps
#define TRUE .t.
#define FALSE .f.

#include && the cdo constants of a previous message

&& need win2k or higher
hidden function MailSmtp(Recipient, cc, bcc, subject, msg, attachment)
	

	*_Show, 'sending mail to ', m.Recipient, ' Subject:', m.Subject

	
	local Success
	Success = TRUE
	
	local ObjMsg, ObjConfig, i, aa[1]
	
	ObjMsg		= CreateObject('CDO.Message')
	ObjConfig	= CreateObject('CDO.Configuration')
	
	do case
	case !inlist(vartype(m.ObjMsg), T_OBJECT)
		assert FALSE
		Success = FALSE 
	
	case !inlist(vartype(m.ObjConfig), T_OBJECT)
		assert FALSE
		Success = FALSE 
	
	otherwise
		
		
		&& (1) config
		
		with m.ObjConfig.Fields
			.Item(cdoSendUsingMethod) = cdoSendUsingPort
			.Item(cdoSMTPServer) = this.smtpServer  && relay.skynet.be
			.Item(cdoSendUserName) = this.smtpUserId  && GregoryAdam@skynet.be
			.Item(cdoSendPassword) = this.smtPassword && haha
			.Item(cdoSMTPServerPort) = this.smtpServerPort && 25
			.Item(cdoSMTPAuthenticate) = 1 && cdobasic
			
#if FALSE				
			if( !IsRunTime())
				&& .Item(cdoImportance)	= 2
				&& .Item(cdoPriority)	= cdoPriorityUrgent
			endif
#endif
			.Update()
		endwith
		
		&& (2) Message
		with ObjMsg
			.Configuration = m.ObjConfig
			
			** .From		= 'test@test.com'
			.To			= m.Recipient
			*.ReplyTo	= 'test@test.com'
			.CC			= iif(empty(m.cc), '', m.cc)
			.bcc		= iif(empty(m.bcc), '', m.bcc)
			.subject	= iif(empty(m.subject), '', m.subject)
			.TextBody	= iif(empty(m.msg), '', m.msg)

                && StringToArray splits comma separated items into an array.  Use alines()
			if( !empty(m.attachment) )
				for i = 1 to StringToArray(m.attachment, @aa)

                                        && If msg empty and my first attachment is htm/html, then I consider it to be the html body
                                        && used to do that in the past.  Had only one html attachment

					do case
                                        case (m.i = 1) and empty(m.msg) and inlist(lower(justext(aa[m.i])), 'htm', 'html')
						.HTMLbody = FileToStr(aa[m.i])
						
					otherwise
						.AddAttachment(aa[m.i])
					
					endcase
				endfor
			endif
			
			if( empty(.Configuration.fields.Item(cdoSendEmailAddress).Value) )
				.Configuration.fields.Item(cdoSendEmailAddress) = 'No@Profile.com'
				local FromId
				FromId = ["] + sys(0) + [" <No@Profile.com>]
								
				*FromId = strtran(m.FromId, '(', '\(')
				*FromId = strtran(m.FromId, ')', '\)')
				
				.From = m.FromId 
				
			endif
#if FALSE
			if( DEBUGMODE_GLOBAL )
				acti screen
				?'cdoSendEmailAddress', .Configuration.fields.Item(cdoSendEmailAddress).Value
				?'cdoSendUserName', .Configuration.fields.Item(cdoSendUserName).Value
				?'cdoSendUserReplyEmailAddress', .Configuration.fields.Item(cdoSendUserReplyEmailAddress).Value
				?
				?'cdoPostUserName', .Configuration.fields.Item(cdoPostUserName).Value
				?'cdoPostUserReplyEmailAddress', .Configuration.fields.Item(cdoPostUserReplyEmailAddress).Value
			endif
#endif		
			Private MailQueue_SMTP_Error
			MailQueue_SMTP_Error = FALSE

			local sError
			sError = on('Error')
			on error MailQueue_SMTP_Error = TRUE
			*=.SaveToFile('\tmp\00.eml')
			
			=.Send()
			on error &sError
			
			do case
			case m.MailQueue_SMTP_Error
				=aerror(ppp)
				
				disp memo like ppp
				
				Success = FALSE
			endcase
			
		endwith
			
		
	
	endcase
	
	return Success
endfunc
*---------------------------------------------------------------------------
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform