Skip to main content

[archive] Creating application of Outlook

  • December 3, 2010
  • 10 replies
  • 0 views

[Migrated content. Thread originally posted on 03 December 2010]

I have successfully created an application of Outlook, which is called by another program, passing variables such as 'subject' 'body' 'email address' and so forth. Works perfectly, but was based on a an example I found so very much 'monkey see, monkey do' from me.
I now wish to send to multiple recipients using a table of email-address I will pass in the calling program so set up a small test. The following code works on the first occurrence but fails on the second occurrence. Exact message is :- 'The item has been moved or deleted' but I cant see why this is happening. Code is:-
perform varying sub from 1 by 1 until sub > 3
modify mailHandle @To = tab-email (sub)
modify mailHandle @Send()
end-perform

I am not sure what the () after the @Send implies, since as I say I am purely basing my program on an example I found, so dont have an explanation of all the example code.

10 replies

[Migrated content. Thread originally posted on 03 December 2010]

I have successfully created an application of Outlook, which is called by another program, passing variables such as 'subject' 'body' 'email address' and so forth. Works perfectly, but was based on a an example I found so very much 'monkey see, monkey do' from me.
I now wish to send to multiple recipients using a table of email-address I will pass in the calling program so set up a small test. The following code works on the first occurrence but fails on the second occurrence. Exact message is :- 'The item has been moved or deleted' but I cant see why this is happening. Code is:-
perform varying sub from 1 by 1 until sub > 3
modify mailHandle @To = tab-email (sub)
modify mailHandle @Send()
end-perform

I am not sure what the () after the @Send implies, since as I say I am purely basing my program on an example I found, so dont have an explanation of all the example code.
The mailItem class has a member Recipients. This has a method Add.
Hence;

MODIFY mailHandle Recipients::Add(tab-email(sub)) should do.

The parenthesis after Send is indicating that Send is a method with no parameters.

Note that if you do:

77 RecipientHandle USAGE HANDLE OF Recipient.
...
| Do loop
MODIFY mailHandle Recipients::Add(tab-email(sub)) GIVING RecipientHandle.
MODIFY RecipientHandle @Type = olTo. | or you could use olCC, olBCC, olOriginator
MODIFY RecipientHandle Resolve() GIVING boolRes
IF boolRes == 0
| bad address
END-IF
| end of loop

You get more control :-)

[Migrated content. Thread originally posted on 03 December 2010]

I have successfully created an application of Outlook, which is called by another program, passing variables such as 'subject' 'body' 'email address' and so forth. Works perfectly, but was based on a an example I found so very much 'monkey see, monkey do' from me.
I now wish to send to multiple recipients using a table of email-address I will pass in the calling program so set up a small test. The following code works on the first occurrence but fails on the second occurrence. Exact message is :- 'The item has been moved or deleted' but I cant see why this is happening. Code is:-
perform varying sub from 1 by 1 until sub > 3
modify mailHandle @To = tab-email (sub)
modify mailHandle @Send()
end-perform

I am not sure what the () after the @Send implies, since as I say I am purely basing my program on an example I found, so dont have an explanation of all the example code.
The mailItem class has a member Recipients. This has a method Add.
Hence;

MODIFY mailHandle Recipients::Add(tab-email(sub)) should do.

The parenthesis after Send is indicating that Send is a method with no parameters.

Note that if you do:

77 RecipientHandle USAGE HANDLE OF Recipient.
...
| Do loop
MODIFY mailHandle Recipients::Add(tab-email(sub)) GIVING RecipientHandle.
MODIFY RecipientHandle @Type = olTo. | or you could use olCC, olBCC, olOriginator
MODIFY RecipientHandle Resolve() GIVING boolRes
IF boolRes == 0
| bad address
END-IF
| end of loop

You get more control :-)

[Migrated content. Thread originally posted on 03 December 2010]

I have successfully created an application of Outlook, which is called by another program, passing variables such as 'subject' 'body' 'email address' and so forth. Works perfectly, but was based on a an example I found so very much 'monkey see, monkey do' from me.
I now wish to send to multiple recipients using a table of email-address I will pass in the calling program so set up a small test. The following code works on the first occurrence but fails on the second occurrence. Exact message is :- 'The item has been moved or deleted' but I cant see why this is happening. Code is:-
perform varying sub from 1 by 1 until sub > 3
modify mailHandle @To = tab-email (sub)
modify mailHandle @Send()
end-perform

I am not sure what the () after the @Send implies, since as I say I am purely basing my program on an example I found, so dont have an explanation of all the example code.
The mailItem class has a member Recipients. This has a method Add.
Hence;

MODIFY mailHandle Recipients::Add(tab-email(sub)) should do.

The parenthesis after Send is indicating that Send is a method with no parameters.

Note that if you do:

77 RecipientHandle USAGE HANDLE OF Recipient.
...
| Do loop
MODIFY mailHandle Recipients::Add(tab-email(sub)) GIVING RecipientHandle.
MODIFY RecipientHandle @Type = olTo. | or you could use olCC, olBCC, olOriginator
MODIFY RecipientHandle Resolve() GIVING boolRes
IF boolRes == 0
| bad address
END-IF
| end of loop

You get more control :-)

[Migrated content. Thread originally posted on 03 December 2010]

I have successfully created an application of Outlook, which is called by another program, passing variables such as 'subject' 'body' 'email address' and so forth. Works perfectly, but was based on a an example I found so very much 'monkey see, monkey do' from me.
I now wish to send to multiple recipients using a table of email-address I will pass in the calling program so set up a small test. The following code works on the first occurrence but fails on the second occurrence. Exact message is :- 'The item has been moved or deleted' but I cant see why this is happening. Code is:-
perform varying sub from 1 by 1 until sub > 3
modify mailHandle @To = tab-email (sub)
modify mailHandle @Send()
end-perform

I am not sure what the () after the @Send implies, since as I say I am purely basing my program on an example I found, so dont have an explanation of all the example code.
Thank you very much, I really appreciate your help, but I just want to make sure I am understanding you correctly. I didnt show all the code, so maybe I wasnt clear on what I want to do. I dont need to add recipients to the same email (although thanks for that tip, it will be useful in future) the body of the email changes slightly for every recipient, so it is a matter of creating the correct body content, sending it, modifying the body, and sending to the next recipient, until everyone has received their personalized email. The reason I didnt include all that in the code in my query, is everything else seems to be OK, the only problem I seem to have is that after the first Send which is fine, the second one fails on the Send with the message I mention although the email address is valid.

[Migrated content. Thread originally posted on 03 December 2010]

I have successfully created an application of Outlook, which is called by another program, passing variables such as 'subject' 'body' 'email address' and so forth. Works perfectly, but was based on a an example I found so very much 'monkey see, monkey do' from me.
I now wish to send to multiple recipients using a table of email-address I will pass in the calling program so set up a small test. The following code works on the first occurrence but fails on the second occurrence. Exact message is :- 'The item has been moved or deleted' but I cant see why this is happening. Code is:-
perform varying sub from 1 by 1 until sub > 3
modify mailHandle @To = tab-email (sub)
modify mailHandle @Send()
end-perform

I am not sure what the () after the @Send implies, since as I say I am purely basing my program on an example I found, so dont have an explanation of all the example code.
Difficult to state. But it sounds to me that you are reusing the same MailItem object, upon setting @To a second time, this may conflict.

If you do not do this, I suggest you do a DESTROY mailHandle and get a new one using OutlookHandle CreateItem for each iteration.

[Migrated content. Thread originally posted on 03 December 2010]

I have successfully created an application of Outlook, which is called by another program, passing variables such as 'subject' 'body' 'email address' and so forth. Works perfectly, but was based on a an example I found so very much 'monkey see, monkey do' from me.
I now wish to send to multiple recipients using a table of email-address I will pass in the calling program so set up a small test. The following code works on the first occurrence but fails on the second occurrence. Exact message is :- 'The item has been moved or deleted' but I cant see why this is happening. Code is:-
perform varying sub from 1 by 1 until sub > 3
modify mailHandle @To = tab-email (sub)
modify mailHandle @Send()
end-perform

I am not sure what the () after the @Send implies, since as I say I am purely basing my program on an example I found, so dont have an explanation of all the example code.
Perfect, that has done the trick, everything now works. My sincere thanks for something definitely worth remembering.

[Migrated content. Thread originally posted on 03 December 2010]

I have successfully created an application of Outlook, which is called by another program, passing variables such as 'subject' 'body' 'email address' and so forth. Works perfectly, but was based on a an example I found so very much 'monkey see, monkey do' from me.
I now wish to send to multiple recipients using a table of email-address I will pass in the calling program so set up a small test. The following code works on the first occurrence but fails on the second occurrence. Exact message is :- 'The item has been moved or deleted' but I cant see why this is happening. Code is:-
perform varying sub from 1 by 1 until sub > 3
modify mailHandle @To = tab-email (sub)
modify mailHandle @Send()
end-perform

I am not sure what the () after the @Send implies, since as I say I am purely basing my program on an example I found, so dont have an explanation of all the example code.
Perfect, that has done the trick, everything now works. My sincere thanks for something definitely worth remembering.

[Migrated content. Thread originally posted on 03 December 2010]

I have successfully created an application of Outlook, which is called by another program, passing variables such as 'subject' 'body' 'email address' and so forth. Works perfectly, but was based on a an example I found so very much 'monkey see, monkey do' from me.
I now wish to send to multiple recipients using a table of email-address I will pass in the calling program so set up a small test. The following code works on the first occurrence but fails on the second occurrence. Exact message is :- 'The item has been moved or deleted' but I cant see why this is happening. Code is:-
perform varying sub from 1 by 1 until sub > 3
modify mailHandle @To = tab-email (sub)
modify mailHandle @Send()
end-perform

I am not sure what the () after the @Send implies, since as I say I am purely basing my program on an example I found, so dont have an explanation of all the example code.
Perfect, that has done the trick, everything now works. My sincere thanks for something definitely worth remembering.

[Migrated content. Thread originally posted on 03 December 2010]

I have successfully created an application of Outlook, which is called by another program, passing variables such as 'subject' 'body' 'email address' and so forth. Works perfectly, but was based on a an example I found so very much 'monkey see, monkey do' from me.
I now wish to send to multiple recipients using a table of email-address I will pass in the calling program so set up a small test. The following code works on the first occurrence but fails on the second occurrence. Exact message is :- 'The item has been moved or deleted' but I cant see why this is happening. Code is:-
perform varying sub from 1 by 1 until sub > 3
modify mailHandle @To = tab-email (sub)
modify mailHandle @Send()
end-perform

I am not sure what the () after the @Send implies, since as I say I am purely basing my program on an example I found, so dont have an explanation of all the example code.
Only thing I'd say with using outlook is that the security aspect is a right pain.
You will have trouble if you ever begin using this with things like say invoice prints when multiple emails are being sent.
All depends on what version of outlook you use of course, however I'd imagine you'll be hitting those security issues.
You might want to look into something called Outlook Redemption or perhaps communicate directly with Microsoft Exchange (assuming you have such a thing)

[Migrated content. Thread originally posted on 03 December 2010]

I have successfully created an application of Outlook, which is called by another program, passing variables such as 'subject' 'body' 'email address' and so forth. Works perfectly, but was based on a an example I found so very much 'monkey see, monkey do' from me.
I now wish to send to multiple recipients using a table of email-address I will pass in the calling program so set up a small test. The following code works on the first occurrence but fails on the second occurrence. Exact message is :- 'The item has been moved or deleted' but I cant see why this is happening. Code is:-
perform varying sub from 1 by 1 until sub > 3
modify mailHandle @To = tab-email (sub)
modify mailHandle @Send()
end-perform

I am not sure what the () after the @Send implies, since as I say I am purely basing my program on an example I found, so dont have an explanation of all the example code.
Good point Shaun!