INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

VFP6 automation

VFP6 automation

(OP)
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


RE: VFP6 automation

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close