Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Capture Mail Content

Former Member
0 Likes
1,332

Dear All,

We are facing a requirement wherein we need to capture the MS Office mail content into our internal table and search for a word in it.

Can we capture the full content of MS Office mail in ABAP?

Waiting for your replies....

With Regards,

Jagan.

Dear All,

We are facing a requirement wherein we need to capture the MS Office mail content into our internal table and search for a word in it.

Can we capture the full content of MS Office mail in ABAP?

Waiting for your replies....

With Regards,

Jagan.

8 REPLIES 8
Read only

Former Member
0 Likes
1,103

Hi Jagannathan,

http://scn.sap.com/docs/DOC-31015

Many thanks

venkat

Read only

0 Likes
1,103

Hi Venkat,

Thanks for your link.We tried our best to find a way..

But we have used workflow for this requirement..

After doing some R&D on OLE, we could capture the data in MS word into our internal table.

We are not using Webdynpro ABAP. Can a mail content in MS Outlook be fetched into our internal table using OLE. or some other way other than Webdynpro ABAP?

We are still bit unclear about this.

Waiting for your replies!!!!

With Regards,

Jagan.

Read only

Former Member
0 Likes
1,103

Hi Jagan,

The way you use MS Word OLE Object.

There is a MAPI object for Outlook. There is not much of a difference how we adapt OLE in .NET and SAP only the syntax changes but the property call and other things remain the same.

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mailitem(v=office.14).aspx

the above link states how to use it in .NET to read mails

The below link also state the way to use

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._mailitem.htmlbody(v=office...

Try to replicate the same.

BR

Read only

0 Likes
1,103

Hi Yakub,

Thanks a lot for your links...Did some R and D on that....Could create a program for sending MS Outlook mail...

But is that possible to search a MS Outlook mail from ABAP via OLE and capture the content of a particular mail?.

With Regards,

Jagan.

Read only

0 Likes
1,103

You can use the Folder object of OLE for MAPI and use the Filter Option

For SAMPLE usage of OLE and Properties there is the usage of VBA

Try to replicate the same.

    Dim Filter As String

    Dim oRow As Outlook.Row

    Dim oTable As Outlook.Table

    Dim oFolder As Outlook.Folder

    'Get a Folder object for the Inbox

    Set oFolder = Application.Session.GetDefaultFolder(olFolderInbox)

    'Define Filter to obtain items last modified after May 1, 2005

    Filter = "[LastModificationTime] > '5/1/2005'"

    'Restrict with Filter

    Set oTable = oFolder.GetTable(Filter)

I hope it works....

BR

Read only

0 Likes
1,103

Hi Yakub,

Thanks a million for your continuous help....

Captured the MS Outlook mail content successfully...

U r Rocking!!!! Full marks to you!!!!

With Regards,

Jagan.

Read only

0 Likes
1,103

Sir,

No marks received... but its fine. received some likes

If not an issue can you share the code.

BR,

Yakub Shah

Read only

0 Likes
1,103

Hi Yakub,

Wanted to give full marks to you Yakub but unfortunately 'i marked this thread as answered'.

I think marks does not matter...Sincere thanks from my end....

Yeah i would love to share my code...

INCLUDE : OLE2INCL.


TYPES: BEGIN OF T_MAIL_BODY,
W_BODY
TYPE STRING,
END OF T_MAIL_BODY.

DATA: W_OUTLOOK TYPE OLE2_OBJECT,
W_NAMESPACE
TYPE OLE2_OBJECT,
W_INBOX
TYPE OLE2_OBJECT,
W_SUBJECT
(100),
IT_MAIL
TYPE STANDARD TABLE OF T_MAIL_BODY,
WA_MAIL
TYPE T_MAIL_BODY,
W_MAIL_ITEM
TYPE OLE2_OBJECT,
INX
TYPE SY-TABIX,
W_SENT_ON
(10),
W_BODY
TYPE STRING,
W_SENDERNAME
(15).

CREATE OBJECT W_OUTLOOK 'OUTLOOK.APPLICATION'.
CALL METHOD OF W_OUTLOOK 'GetNameSpace' = W_NAMESPACE
EXPORTING
#1
= 'MAPI'.
CALL METHOD OF W_NAMESPACE 'GetDefaultFolder' = W_INBOX
EXPORTING
#1
= 5.  “3;Deleted items,4;Outbox,5;Sent “Items,6;Inbox,9;Calendar,10;Contacts,11;Journal,12;Notes,13;Tasks

CLEAR: INX. “Counter for searching mails one by one, for testing i kept it as 30(might have used "do loop as DO 30 times...But just tested like this
DO.

IF INX = 30.
EXIT.
ENDIF.

INX
= INX + 1.
CALL METHOD OF W_INBOX 'Items' = W_MAIL_ITEM
EXPORTING
#1
= INX.
IF SY-SUBRC = 0.
GET PROPERTY OF W_MAIL_ITEM 'Subject'           = W_SUBJECT.
IF W_SUBJECT = ‘Subject of the mail’.
GET PROPERTY OF W_MAIL_ITEM 'SentOn'   = W_SENT_ON.
GET PROPERTY OF W_MAIL_ITEM 'SenderName'   = W_SENDERNAME.
GET PROPERTY OF W_MAIL_ITEM 'Body'        = W_BODY.
WA_MAIL
-W_BODY = W_BODY.
APPEND WA_MAIL TO IT_MAIL.
CALL METHOD OF W_MAIL_ITEM 'DISPLAY'.
ENDIF.
ENDIF.

ENDDO.

BREAK-POINT.

With Regards,

Jagan