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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending mails 1

Status
Not open for further replies.

fluppe689

Programmer
Jul 11, 2008
75
BE
Hello Experts,

Another question
I send mails from vfp9 sp1.
my code is :

IF thisformset.frmbest.cb_urgent.value = 1
m.urgent = "JA/OUI/YES"
ELSE
m.urgent = "NORMAAL/NORMAL/NORMAL"
ENDIF

subject = "ONZE REF/NOTRE REF/OUR REF " + STR(thisformset.frmbest.tb_bestelnr.value,10,0) + " Code: " +;
ALLTRIM(THISFORMSET.frmbest.tb_bskode.VALUE) + " URGENT " + m.urgent

body = "Geachte Heer/ Mevrouw Cher(e) Monsieur/Madame Dear Sirs"+ CHR(13) + ;
"Gelieve bijgaande bestelling te noteren en ons zo vlug mogelijk de leveringsdatum te laten weten"+CHR(13)+;
"Gelieve ook asap te laten weten als er partnumbers veranderd zijn in deze bestelling"+CHR(13)+ CHR(13);
"Veullez noter notre commande ci-incluse. Veullez nous informer au plus vite la date de livraison"+CHR(13)+;
"Veullez aussi nous informer aussi au plus vite si il y a des partnumber qui ont changé"+CHR(13)+CHR(13)+;
"Please note our order included and let us know the delivery date as soon as possible"+CHR(13);
"Please let us also know if there are any number changes"+CHR(13)+CHR(13)+;
m.username



o=CREATEOBJECT("outlook.application")
oitem = o.createitem(0)
oitem.subject = subject
oitem.TO = ALLTRIM(thisformset.frmbest.tb_aan.value)
oitem.cc = ALLTRIM(thisformset.frmbest.tb_cc.Value)
oitem.bcc = ALLTRIM(thisformset.frmbest.tb_bcc.Value)
oitem.body = body
oitem.Attachments.ADD("&bijlage")
*
oitem.DISPLAY
o=.NULL.

this works fine if outlook is already started.
if outlook isn't started this thing doesn't work.
is there any way of knowing if outlook is started and when it isn't started how can i start outlook automaticaly
Whet also doesn't work I see now the field BCC is not updated.

wfg,

Filip Merlier
 
"this works fine if outlook is already started.
if outlook isn't started this thing doesn't work."[/B]

What do you mean it doesn't work?

Do you get an error message?
Does the email appear within one of Outlook's folders, but is not SENT?
What?

I don't see where you actually issue the Outlook SEND

You also say - "What also doesn't work I see now the field BCC is not updated."
Why aren't you using the TEXT properties from your Form's Textboxes?
Code:
oitem.cc  = ALLTRIM(thisformset.frmbest.tb_cc.Text)

Good Luck,
JRB-Bldr

 
Dear JRB-Bldr

the error i get is in the
oitem = o.createitem(0)
I happens only while Outlook isn't openened yet

Error is : OLE Dispatch exception code 4096 form Microsoft office outlook : fout bij het uitvoeren van de bewerking...

I try to translate the latest phrase :
error during execution of the (bewerking = manipulation).
Everything works fine when outlook is already opened.

WFG,

FILIP MERLIER
 
It's part of outlooks security to ask the user, if he allows another program to send mail.

The outlook user is promted to allow access, this promt dialog has a timeout, and if that expires the missing reaction is interpreted as no.

All you can do in foxpro is this:
Code:
Try
  oitem   = o.createitem(0)
Catch To loException when loException.ErrorNo=4096
  Messagebox(loException.Details)
* or
* Messagebox("You didn't allow this program to use outlook or outlook isn't open, please try again",0,"this program")
Endtry

If Vartype(oitem)="O"
   oitem.subject = ...
   ...
Endif

so you catch, if oitem couldn't be created and display an error message.

Bye, Olaf.
 
sorry, one adjustment.

It's ole error 4096, but vfp will catch it as errorno = 1427 or 1429. So change that to

Catch To loException when inlist(loException.ErrorNo,1427,1429)

Bye, Olaf.
 
Olaf,

Thanks is in it place here.
Your tip does his work very good.

Wfg,

Filip
 
Another approach is to use Redemption which 'trick's Outlook and gets around the annoying Outlook Security Patch which is the cause of your difficulties. We use it to programatically send 100's of emails to clients every day.

To find it go to:
Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top