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..
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