Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Redemption Problem
Message
De
13/03/2006 07:47:43
Chris Ross
Lothian Valuation Joint Board
Edinburgh, Royaume Uni
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Redemption Problem
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01103674
Message ID:
01103674
Vues:
56
I have a problem when sending emails in my program. I'm using redemption to get round the security warnings outlook generates.

The code (attached below) works fine when I've got outlook open though when i try to run the same program with outlook closed i get a 'Microsoft Office Outlook has encountered a problem and needs to close. We are sorry for the inconvenience.' error with an option to restart Outlook.

Can anyone tell me if what the problem is with this code - I'm running this code multiple times throughout the program?

The code also appears to work when i run the code in debug mode??
LOCAL oOutLook, oItem, oSafeItem
TRY
  oOutlook = CREATEOBJECT('Outlook.Application') && open outlook
  oSafeItem = CREATEOBJECT('Redemption.SafeMailItem') && open redemption

  oItem = oOutlook.createitem(0) && create new mail message
  oSafeItem.Item = oItem && create safe item object 

  WITH oSafeItem

    SELECT ReportOut   
    SCAN  
      &&Get To recipients   
      IF &lcEmailRepName = 1
        .Recipients.Add(ALLTRIM(Email)) 
      ENDIF 
       
      &&Get CC Recipients 
      IF &lcEmailRepName = 2
        oCCRecpients = .Recipients.Add(ALLTRIM(Email))    
        oCCRecpients.Type = 2
      ENDIF   
    ENDSCAN
    .Recipients.ResolveAll 
    
    .subject = This.EmailTitle
    
    lcAttachmentNumber = 1
    **Check for multiple attachments
    DO WHILE NOT EMPTY(This.emailattachments[lcAttachmentNumber])
      .Attachments.Add(This.emailattachments[lcAttachmentNumber])
      lcAttachmentNumber = lcAttachmentNumber + 1  
    ENDDO
    
    *.HTMLBody = lcHTMLString
    .body = This.Emailbody
    .Save()
    .Send()
  ENDWITH
CATCH
  MESSAGEBOX('Email - ' + This.EmailTitle + ' could not be sent.',64)
ENDTRY  

oOutlook = .NULL.

RELEASE oItem
RELEASE oOutlook
RELEASE oSafeItem
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform