cancel
Showing results for 
Search instead for 
Did you mean: 

Outlook Appointment in powerbuilder

Former Member
0 Kudos

Please can you anybody advise me how to get the code in powerbuilder using 11.2 . I am using Microsoft exchange dlls for this

private void button2_Click(object sender, EventArgs e)
{
try
{

ExchangeService service = new ExchangeService();
string username = mycompany+ "\\" + "usersid";
service.Credentials = new WebCredentials(username, "myusername");
service.AutodiscoverUrl("myname@mycompany.com");
Appointment appointment = new Appointment(service);
appointment.Subject = "Testing Holiday";
appointment.Start = DateTime.Now;
appointment.End = appointment.Start.AddHours(1);
appointment.Save();
}

catch (Exception ex)
{
MessageBox.Show("The following error occurred: " + ex.Message);
}
}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Take a look at this article on how to call .Net from PowerBuilder.

http://blogs.artinsoft.net/Mrojas/archive/2009/03/03/Calling-NET-from-PowerBuilder.aspx

Answers (3)

Answers (3)

rodolfo_reyes
Explorer
0 Kudos

Hi,

In the old forum they did more or less the same question. And this was what they found:

https://archive.sap.com/discussions/thread/3532310

Former Member
0 Kudos

I googled this and it appears that the API you are using is only available to .Net applications. You could create a COM control in C# and then call it from PowerBuilder. I haven't done that myself but I know it is possible.

Former Member
0 Kudos

I have created the consol application in C# using the API and now I am calling this exe from powerbuilder by passing argument and it is working fine.

Is that the way you advised me to create COM control in C# ?

Former Member
0 Kudos

Hi Polachan,

Here is an extract from my code:

...
...
s_inhalt = 'TEXT'
l_outlook_mm = long(s_inhalt)
s_categories = ''
ole_outlook = Create OLEObject
l_result = ole_outlook.ConnectToNewObject("outlook.application")
if l_result = 0 then
ole_item = ole_outlook.CreateItem(1)
l_beginn_zeit = '08:00'
l_reminder_outlook = 1
s_attendees_outlook = ''1
s_required_attendees = ''
l_show_kategories = 1
if isnull( l_show_kategories ) then l_show_kategories = 0
if isnull(l_beginn_zeit) then l_beginn_zeit = 0
ti_zeit = time(string(l_beginn_zeit,'00:00') + ':00.000000' )
dti_beginn_datum = datetime(date(dti_beginn_datum),ti_zeit)
ole_item.start = dti_beginn_datum
ole_item.categories = s_categories
if l_show_kategories = 1 then
ole_item.showcategoriesdialog
end if
dti_ende_datum = '11.01.2016'
if isnull(dti_ende_datum) then dti_ende_datum = dti_beginn_datum
l_ende_zeit = '11:30'
if isnull(l_ende_zeit) then l_ende_zeit = l_beginn_zeit
ti_zeit = time(string(l_ende_zeit,'00:00') + ':00.000000' )
dti_ende_datum = datetime(date(dti_ende_datum),ti_zeit)
ole_item.end = dti_ende_datum
l_termin_art = 1
if isnull(l_termin_art) then l_termin_art = 0
s_termin_art_bez = 'TEST'
s_subject = s_termin_art_bez + ' ' + string(l_kdnr) + ' ' + s_name_und_ort
ole_item.subject = s_subject
s_body = ''
if isnull(s_stichwort) then s_stichwort = ''
if isnull(s_notiz) then s_notiz = ''
if len(s_stichwort) > 0 then
s_body = s_body + s_stichwort + '~r~n' + '~r~n'
end if
if len(s_notiz) > 0 then
s_body = s_body + s_notiz + '~r~n' + '~r~n'
end if
ole_item.body = s_body
s_termin_ort = 'ORT'
if len(trim(s_termin_ort)) > 0 then ole_item.Location = s_termin_ort
if l_reminder_outlook > 0 then
ole_item.reminderSet = True
ole_item.reminderminutesbeforestart = l_reminder_outlook
end if
if not ( isnull( s_required_attendees ) or len( trim( s_required_attendees ) ) = 0 ) then
ole_item.requiredattendees = s_required_attendees
end if
if not ( isnull( s_attendees_outlook ) or len( trim( s_attendees_outlook ) ) = 0 ) then
ole_item.optionalattendees = s_attendees_outlook
end if
ole_item.save
ole_item.display
l_result = ole_outlook.disconnectObject()
destroy ole_item
destroy ole_outlook
end if
...
...

I hope you understand it. You must translate German words if you are unknown.

André Rust

Former Member
0 Kudos

Many Thanks Andre

Many Thanks for your help . Your code only work with local outlook application. I would like to work with Exchange server by username and password. Please can you look my c# code. My code is working fine in C#. But I like to convert the code from C# into powerbuilder