Highlighted
Absent Member.
Absent Member.
1036 views

Calling Outlook From Visual Cobol

Jump to solution

[Migrated content. Thread originally posted on 15 August 2011]

Hi All,

Im trying to call Outlook from with in Visual Cobol using the following code:-

method-id. "button1_Click" final private.
01 ls-call string.
procedure division using by value sender as object e as type "System.EventArgs".
set ls-call to '"C:\Program Files\Microsoft Office\Office11\Outlook.exe" /c ipm.note'
invoke type "System.Diagnostics.Process"::"Start"(ls-call)
end method "button1_Click".

However its returning an error "the system cannot find the file specified"

I can run this from the command prompt and it works ok, any ideas pls.

Kind regards

Neil.
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Contributor
Micro Focus Contributor

RE: Calling Outlook From Visual Cobol

Jump to solution
Neil, I suspect the error is caused because you are passing arguments to the executable. According to the documentation (http://msdn.microsoft.com/en-us/library/53ezey2s.aspx) arguments are not supported. You'd have to use a ProcessStartInfo object. E.G.

01 procStartInfo type System.Diagnostics.ProcessStartInfo.
...
set procStartInfo to new System.Diagnostics.ProcessStartInfo
set procStartInfo::Arguments to "/c ipm.note"
set procStartInfo::FileName to "c:\Program Files\Microsoft Office\Office11\Outlook.exe"
invoke type System.Diagnostics.Process::Start(procStartInfo)

If what you are trying to accomplish is to send an e-mail it's probably better to use the built in .NET classes rather than exec'ing the mailer directory. Have a look at the System.Net.Mail namespace (http://msdn.microsoft.com/en-us/library/system.net.mail.aspx)

View solution in original post

0 Likes
2 Replies
Highlighted
Micro Focus Contributor
Micro Focus Contributor

RE: Calling Outlook From Visual Cobol

Jump to solution
Neil, I suspect the error is caused because you are passing arguments to the executable. According to the documentation (http://msdn.microsoft.com/en-us/library/53ezey2s.aspx) arguments are not supported. You'd have to use a ProcessStartInfo object. E.G.

01 procStartInfo type System.Diagnostics.ProcessStartInfo.
...
set procStartInfo to new System.Diagnostics.ProcessStartInfo
set procStartInfo::Arguments to "/c ipm.note"
set procStartInfo::FileName to "c:\Program Files\Microsoft Office\Office11\Outlook.exe"
invoke type System.Diagnostics.Process::Start(procStartInfo)

If what you are trying to accomplish is to send an e-mail it's probably better to use the built in .NET classes rather than exec'ing the mailer directory. Have a look at the System.Net.Mail namespace (http://msdn.microsoft.com/en-us/library/system.net.mail.aspx)

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Calling Outlook From Visual Cobol

Jump to solution
Hi Simon,

Thanks for that info it works a treat.

Kind regards

Neil.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.