("Outlook.Application")

89 views
Skip to first unread message

timepro timesheet

unread,
Jul 15, 2021, 5:18:43 AMJul 15
to
hello all:

at some endusers my app crashes at line#28.
but, at most users, that exact same app works fine.

tia

***********
func oemail(o1)
***********
1 o1=if(empty(pcount()),'O',o1)
2 if upper(substr(os(),9,2))='XP'.or.upper(substr(os(),9,2))='VI'
3 message('works under win7/8/10')
4 end
5 toto=if(empty(toto),alltrim(client->clientst),toto)
6 tsubject=if(!empty(tsubject),tsubject,'PFA')
7 attch=pdfname && e.g.: diskname()+':\tax\gst\A001clientbills21-22.pdf'
8 tbody=if(empty(tbody),trim(client->clientname),tbody)
9 tbody1=if(empty(tbody1),trim(client->clientadr1)+', '+trim(client->clientadr2),tbody1)
10 tbody2=if(empty(tbody2),trim(client->clientcity),tbody2)
11 tbody+="<br>"+tbody1+"<br>"+tbody2
12 email=.t.
13 TRY
14 oOutlook:=GetActiveObject("Outlook.Application")
15 oOutlook:=CreateObject("Outlook.Application")
16 CATCH
17 dcr(23,01,24,79,xw)
18 mymess(23,39,'outlook application not installed/activated in this system',xm,xy,fcn,6,6,900)
19 mymess(24,39,'app may crash',xm,xy,fcn,6,6,900);inkey(.5);inkey(15)
20 email=.f.
21 END
22 if email
23 oMsg:=oOutlook:CreateItem(0)
24 oMsg:GetInspector()
25 oMsg:TO := toTO
26 oMsg:Subject := tSubject
27 oMsg:HTMLBody := tbody
28 if !empty(attch);oMsg:Attachments:add(Attch);end && CRASHES HERE (attch is never empty)
29 oMsg:Display(.f.)
30 end
31 ...
32 ...
33 ...
34 ...

Ella Stern

unread,
Jul 15, 2021, 7:46:29 AMJul 15
to

Reinaldo

unread,
Jul 15, 2021, 11:21:22 AMJul 15
to
How about testing if Attch is Nil?

Reinaldo.

timepro timesheet

unread,
Jul 19, 2021, 1:25:24 AMJul 19
to
Attch is not nil.

timepro timesheet

unread,
Jul 20, 2021, 6:51:19 AMJul 20
to

if !empty(attch);oMsg:Attachments:add(Attch);end && CRASHES HERE

earlier code
pdfname='\tax\pdffiles\'+pdfname
but after i added diskname() [pdfname=diskname()+':\tax\pdffiles\'+pdfname ]
it works fine...

is diskname() mandatory, even if the app (exe) is residing in C:\TAX and outlook is also installed in C:

thanks



CV

unread,
Jul 20, 2021, 3:44:07 PMJul 20
to
hi

It needs to use a fully qualified pathname like drive:\directory\subdir\file.ext as in C:\Temp\MyDir\MyPdf.pdf

Regards
Claudio Voskian
Reply all
Reply to author
Forward
0 new messages