Hello Experts,
Ive Created a small program that scans through my email and automatically converts word docs to pdf and sends email back to sender. However, if there are no emails with subject = Convert2PDF found it results in error and crashes my application.
Ive googled around and came accross a similar situation, but i get a nesting error
URL:
Any help is much appreciated
Ive Created a small program that scans through my email and automatically converts word docs to pdf and sends email back to sender. However, if there are no emails with subject = Convert2PDF found it results in error and crashes my application.
Ive googled around and came accross a similar situation, but i get a nesting error
URL:
Code:
local nFolder
nFolder = 6 &&inbox folder
lbOpenOutlook = .f.
on error lbOpenOutlook =.t.
oOutLook = getobject(,"Outlook.Application") &&if outlook is not open this will cause an error and thus set lbOpenOutlook to true
on error
if lbOpenOutlook && if true Outlook needs to be opened
oOutLook=createobject("Outlook.Application")
endif
onamespace = oOutLook.getnamespace("MAPI")
oinbox = onamespace.getdefaultfolder(nFolder)
loitems = oinbox.items
for each loitem in loitems
if loitem.subject = 'Convert2PDF'
loitem.subject = 'Convert2PDF'
loitem.sender
?loitem.sender.address
lcSenderAddress = loitem.sender.address
lnNumberofAttachments=loitem.attachments.count
for nAttachmentLoop = 1 to lnNumberofAttachments
lcAttachmentname= "c:\"+loitem.attachments.item(nAttachmentLoop).filename
loitem.attachments.item(nAttachmentLoop).SaveAsFile (lcAttachmentname)
loitem.delete
NEXT
ENDIF
NEXT
Any help is much appreciated