Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP6 automation

Status
Not open for further replies.
Mar 13, 2017
8
PH
FUNCTION SENDREPORT
parameter dfrom, dto
repstat=1
* LOCAL loapp as outlook.application, mynewmsg as outlook.message, ;
* lomailto as string

IF FILE("D:\AISLMAIN\REPORT\OUTPUT\REPORT.DBF")
* run /N2 "c:\program files\microsoft office\office12\outlook.exe"
objWMIService = GETOBJECT("winmgmts://./root/cimv2")
colItems = objWMIService.ExecQuery("Select * From Win32_Process Where Name = 'outlook.exe'")
if colitems.count=0
run /N "c:\program files\microsoft office\office12\outlook.exe"
do tpauser WITH '10'
endif
lomailto="xxxx@dsl.net"
loApp = GETOBJECT(,'Outlook.application')
mynewmsg = loApp.Createitem(olmailitem)
With mynewmsg
.recipients.add(lomailto)
.Attachments.Add("D:\AISLMAIN\REPORT\OUTPUT\REPORT.DBF")
if file("D:\AISLMAIN\REPORT\TRANFILE.DBF")
.Attachments.Add("D:\AISLMAIN\REPORT\OUTPUT\TRANFILE.DBF")
endif
if file("D:\AISLMAIN\REPORT\OUTPUT\CDC_INFO.DBF") and file("D:\AISLMAIN\REPORT\OUTPUT\CDC_DTLS.DBF")
.Attachments.add("D:\AISLMAIN\REPORT\OUTPUT\CDC_INFO.DBF")
.Attachments.add("D:\AISLMAIN\REPORT\OUTPUT\CDC_DTLS.DBF")
endif
if file("D:\AISLMAIN\REPORT\OUTPUT\DEP_INFO.DBF") and file("D:\AISLMAIN\REPORT\OUTPUT\DEP_DTLS.DBF")
.Attachments.add("D:\AISLMAIN\REPORT\OUTPUT\DEP_INFO.DBF")
.Attachments.add("D:\AISLMAIN\REPORT\OUTPUT\DEP_DTLS.DBF")
endif
if file("D:\AISLMAIN\REPORT\OUTPUT\ISSUED.DBF")
.Attachments.add("D:\AISLMAIN\REPORT\OUTPUT\ISSUED.DBF")
endif
if file("D:\AISLMAIN\REPORT\OUTPUT\IFMFILE.DBF")
.Attachments.add("D:\AISLMAIN\REPORT\OUTPUT\IFMFILE.DBF")
endif
.subject="AISL Report "+DTOC(dfrom)+" - "+DTOC(dto)
.htmlBody=" Auto reporting. "+DTOC(dfrom)+" - "+DTOC(dto)+". Generation:"+DTOC(date())+" "+time()
.send()
endwith
* loapp.quit
release loapp, mynewmsg,lomailto,objWMIService
tmp1="D:\AISLMAIN\REPORT\*.DBF"
delete file &tmp1
* run /N2 "c:\program files\microsoft office\office12\outlook.exe"
ELSE
repstat=0
ENDIF

RETURN repstat



we will migrate our emails, so please help me out here..

i have a program here, when i change the email addres to mis@some.com and run the program it always using xxxx@dsl.net. even though i change it.

i tried .recipients.add('mis@some.com') wont work also it always using xxx@dsl.net
i tried replacing xxxx@pdsl.net to mis@some.com wont work also
iam confused i cant find any more solutions

i attached the whle prg hope anyone can help me


 
 http://files.engineering.com/getfile.aspx?folder=ef3fea7a-5a78-48fe-9dac-b3c468b9654e&file=aislupldsh.prg
First you should never post mail addresses. You may edit your post and anonymize the adresses

Are you sure you execute the modified code? If you run an EXE you first have to compile/build, before your new code really runs, just changing a PRG changes its FXP file at max, not an APP or EXE.

Run this standalone as a test, so open up a new PJX and create a PRG:
Code:
loOutlook = CreateObject("Outlook.Application")
loMail = loOutlook.CreateItem(0)
loMail.to = "someone@somewhere.com"
loMail.subject="Test"
loMail.body="Test"
loMail.send()

Run that. If it only arrives at whatever address you put into loMail.to, this ensures Exchange or Outlook don't have any further influence here.

A long shot guess: .recipients.add(lomailto) only adds recipients, it doesn't change them, Is the count of recipients already 1 before you use that?
I don't even know how it would work, but the recipient you don't want anymore is perhaps set up as a standard recipient in your outlook or exchange server. Maybe under the condition your sending address is some certain address. If there is such an automatism I'd look for it in Exchange rather than in an Outlook client.

I explicitly used the .to property of the mail item here, instead of recipients.add, it should override any other setting you already have when creating the mail. Something interfereing with that would need to be external, i.e. Exchange Server, which is the first next instance getting the mail after .send() and able to change the mail before it goes out further into the internet.

Bye, Olaf.

Edit: I see you modified the addresses as suggested, thanks for that. A problem with that is your original post can be seen in the post's history. You should red flag your post (don't worry, this does not discredit or red flag yourself), and in the accompanying text ask staff to remove the initial post text. I could red flag your post myself, but I want you to stay on top, know what's going on and also learn what works here and how.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top