Click here to Skip to main content
15,887,361 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've set of code of VFP which i created to send mail. It is working fine but i wanted to change send email address. Earlier i was using a rediffmail id where i'm able to hide the original email id from recipient.
For Ex : if i'm sending mail through abc@rediff_maildomain.com, i'll specifiy from: def@rediff_maildomain.com. For recipient, only def@rediff_maildomain.com was visible.
But i now i want to change the base mail id to abc@gmail.com instead abc@rediff_maildomain.com and i want sender address as 'def@rediff_maildomain.com' oonly.
But it is still showing abc@gmail.com only.

Code is below..

C#
Parameters  strToo As String,strcc As String,strbc As String, strSubj As String, strMsg As String,mailhead As String,mailfoot As String,Attachment As String, datesessionid
Local feedback
Local sucess
Set DataSession To datesessionid
Try
	Local lcSchema, loConfig, loMsg, loError, lcErr
	lcErr = ""
	lcSchema = "http://schemas.microsoft.com/cdo/configuration/"
	loConfig = Createobject("CDO.Configuration")
	With loConfig.Fields
		.Item(lcSchema + "smtpserver") = "smtp.gmail.com"
		.Item(lcSchema + "smtpserverport") = 465
		.Item(lcSchema + "sendusing") = 2
		.Item(lcSchema + "smtpauthenticate") = .T.
		.Item(lcSchema + "smtpusessl") = .T.
		.Item(lcSchema + "sendusername") = "abc@gmail.com"
		.Item(lcSchema + "sendpassword") = "1234"
		.Update
	Endwith
	loMsg = Createobject ("CDO.Message")
	With loMsg
		.Configuration = loConfig
		.From = "def@rediff_maildomain.com"
		.To = strToo
		.CC = strcc
		.Subject = strSubj
		.HTMLBody = strMsg
		.Send()
	Endwith
Catch To loError
	lcErr = [Error: ] + Str(loError.ErrorNo) + Chr(13) + ;
		[Line: ] + Str(loError.Lineno) + Chr(13) + ;
		[Message: ] + loError.Message
Finally
	Release loConfig, loMsg
	Store .Null. To loConfig, loMsg
  IF EMPTY(lcErr)
    MESSAGEBOX("The Email was sent successfully", 64, "Auto Mail")
  ELSE
    MESSAGEBOX(lcErr, 16 , "Error")
  ENDIF
Endtry
If Empty(lcErr)
	Return '1'
Else
	MESSAGEBOX(lcErr, 16 , "Error")
	RETURN '0'
ENDIF
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900