Sponsored Content
Top Forums Shell Programming and Scripting Reading Mail attachments using unix Post 302573782 by ygemici on Tuesday 15th of November 2011 01:58:35 PM
Old 11-15-2011
Quote:
Originally Posted by srikanthkadapal
bt(btitish telecom) has provided a mail account where we receive .csv attachments.through programing we need to read the attahments and insert the data into our data base tables..
iam new new to UNIX and i knew very basic things only..
what i need here is i need to connect to the mail box for every 3 mins and save the attachments of all the mails in the inbox to a folder then delete all the mails from inbox.

it will be greateful if u can provide me some sample code ...
hi,srikanthkadapal

firstly you must read some documents related this ssue.
i havent tried it before.but i think you can do it after some packages installs and configure these.

-> first stage (fetchmail)
you can use fetchmail for check a pop3 account and download mail from remote IMAP and POP servers and/or save it into local mailboxes(if we desire this).
* if it is not installed on the system then install appropriate fetchmail pckg.
* configure to your account settings in "~./fetchmailrc"
*
Code:
# fetchmail -d 180 # (for 3 mins)

for these you can look this page
Using fetchmail

-> second stage (procmail+metamail)
* install procmail (it is simply a mda for forwarding mails to separate folders)
* install metamail (for decode,display and save non-text mails and/or and find the correct program for mime based files (for ex..if your attachment is a jpg then it calls convenient jpg viewer on your system but we dont use this now)
and for these you can look at this page
Howto: receive mail and save attachment with fetchmail, procmail and metamail | /home/tom

i hope this will be helpfull..

regards
ygemici
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

mail attachments

I'm writing scripts on HP-UX. Is there a way to attach a file to a mail message. I don't want to imbed the data in the mail message. (1 Reply)
Discussion started by: Multithreaded
1 Replies

2. UNIX for Dummies Questions & Answers

file name got cut when using mail attachments

I am using the following command to send a zip file as an attachment to my internet email-id. uuencode ABC_DEFG_HIJ.zip ABC_DEFG_HIJ.zip | mail -s "attachment from shell" pal@yahoo.com Eventhough i have given the attached file as 'ABC_DEFG_HIJ.zip', when i receive the mail in my internet... (3 Replies)
Discussion started by: Pal
3 Replies

3. UNIX for Dummies Questions & Answers

Can you e-mail files as attachments from unix to windows?

Another question if you guys don't mind, if you do this: cat * |mailx -s xxxxx <email> it will send files to a email address displayed as sdout, is there a quick way to send files to a e-mail address but as a attachement? Say if I renamed files to .xls on unix, and sent them to a e-mail... (4 Replies)
Discussion started by: nj78
4 Replies

4. UNIX for Dummies Questions & Answers

sending attachments in mail

Hi , i have tried the following command to send an email with an attachment its working fine but i am getting mail with the embeded content inside the mail that too truncated. i wanted it as an attachment. /usr/lib/sendmail -F "MAC SIA" address "rajendra@abc.com.sg" -t <... (6 Replies)
Discussion started by: rajendragora
6 Replies

5. AIX

Send mail attachments and have a mail body

Hi, How can I send mail attachments from shell script (AIX) and have a mail body as well ? Thanks in advance. (1 Reply)
Discussion started by: shibajighosh
1 Replies

6. Solaris

mail with attachments

I want to send a mail with three attachments, but nothing happened. I tried it with mail and mailx. Are there special options for these commands or is it not possible to send mails under Solaris with attachments? Must there be special adjustments in the environment? Can anyone give an... (6 Replies)
Discussion started by: ninjadan
6 Replies

7. UNIX for Advanced & Expert Users

Mail attachments getting corrupted...

Hi , Whenever I try to send mails with attachments to external email Id's the attachment is not encoded properly which appears along with body (text) of the mail. The attachement is always getting corrupted. Can anyone please suggest a solution. Regards, Sandipan (1 Reply)
Discussion started by: Sandipan
1 Replies

8. Shell Programming and Scripting

e-mail with multiple binary attachments!

Hi, I have to send email from UNIX with multiple excel attachments and the sender name needs to be customized (sender name need not to be UNIX user). I have checked many ways from this forum and other sources. But, nothing did work for me. Please help me! thanks, Raja. (1 Reply)
Discussion started by: smr_rashmy
1 Replies

9. Shell Programming and Scripting

unix email attachments in web mail

Hi, Request you to please help on my issue. My issue is: We are able to send the log files as an email attachment. We are able to get the attachment in our inbox. But when we try to see in web mail, instead of the attachment, junk characters are displaying. Appreciate your help. Regards,... (10 Replies)
Discussion started by: gi.srinivas
10 Replies

10. Shell Programming and Scripting

Adding Attachments to mail

Hi, I need to send a mail with html code in body and an attachment along with the body and subject. The html code must display a table with data in it in the mail. I have tried the 'sendmail' command, but I am am able to display the table in the mail and unable to attach an attachment. ... (5 Replies)
Discussion started by: Durga Prasad NK
5 Replies
OPENCHANGECLIENT(1)					     OpenChange Users' Manual					       OPENCHANGECLIENT(1)

NAME
openchangeclient - MAPI command line messaging tool SYNOPSIS
openchangeclient [-?SFmDV] [-?|--help] [--usage] [-f|--database STRING] [--pf] [-p|--profile STRING] [-P|--password STRING] [-S|--sendmail] [--sendappointment] [--sendcontact] [--sendtask] [--sendnote] [-F|--fetchmail] [-G|--storemail STRING] [-i|--fetch-items STRING] [--freebusy=STRING] [--force] [--delete=STRING] [-u|--update STRING] [-m|--mailbox] [-D|--deletemail] [-A|--attachments STRING] [-I|--html-inline STRING] [-W|--html-file STRING] [-t|--to STRING] [-c|--cc STRING] [-b|--bcc STRING] [-s|--subject STRING] [-B|--body STRING] [--location=STRING] [--label=STRING] [--dtstart=STRING] [--dtend=STRING] [--busystatus=STRING] [--taskstatus=STRING] [--importance=STRING] [--email=STRING] [--fullname=STRING] [--cardname=STRING] [--color=STRING] [--notifications] [--folder=STRING] [--mkdir] [--rmdir] [--userlist] [--folder-name=STRING] [--folder-comment=STRING] [-d|--debuglevel STRING] [--dump-data] [--private] [--ocpf-file=STRING] [--ocpf-dump=STRING] [--ocpf-syntax] [--ocpf-sender] [-V|--version] DESCRIPTION
openchangeclient is a MAPI command line tool designed to facilitate mail send, receive and delete operations using the MAPI protocol. It also provides operations on tasks, contacts (address book) and calendar operations. COMMANDS
--fetchmail -F Fetch Exchange user mails from the inbox and display general information from the mails on the standard output. --storemail=DIRECTORY -G Store mail attachments to the local filesystem in the specified directory. This is the normal way to retrieve attachments. --fetch-items=STRING -i Retrieve specific items from Exchange default folders. Possible value for STRING are Mail, Appointment, Contact, Task, Note. --mkdir Create a folder within the mailbox or public folders store hierarchy. This command requires that the --folder-name option be used to specify the name of the folder to create. --rmdir Deletes a folder within the mailbox or public folders store hierarchy. This option requires that the --folder-name option be used to specify the name of the folder to delete. --mailbox -m Display the user mailbox folder hierarchy with folder names, folder comments, the folder type, number of unread items in the folder and total number of items in the folder. --notifications Monitor NEWMAIL notifications in the Inbox folder and display summary on standard output. --sendmail -S Send a mail to a user belonging to the Exchange organization. This requires specifying one or more recipients (see the --to, --cc and --bcc options), a subject (see the --subject option) and a body (see the --body, --html-file and --html-inline options). --sendappointment Create an appointment in the default calendar folder. --sendcontact Create a contact in the default contact folder. --sendtask Create a task in the default task folder. --sendnote Create a note in the default notes folder. --deletemail -D Delete a mail from the exchange user mailbox. This requires use of the --subject option to specify the mail to be deleted. --userlist Display the users listed in the address book. --delete=STRING Delete a specified item from the store by ID number. --ocpf-dump=STRING Download a message (specified by the argument, which must be the folder ID and unique message ID for the message) as OCPF format. The message will be saved to a file given by the message ID, followed by a suffix of .ocpf See the separate (HTML) documentation for libocpf for more information on the OCPF format. --ocpf-sender Send a message given in OCPF format to the server. This requires use of the --ocpf-file option to specify the file to load from. See the separate (HTML) documentation for libocpf for more information on the OCPF format. --ocpf-syntax Check the syntax of an OCPF file. This does not perform any network operations. This requires use of the --ocpf-file option to spec- ify the file to load from. See the separate (HTML) documentation for libocpf for more information on the OCPF format. --freebusy=STRING Fetch the free / busy status for the user specified by the string. You will usually need to use the --pf option (see below) since free / busy status is normally obtained from the public folder store. OPTIONS
--database=DATABASE -f Set the MAPI profile database. If no database is specified, then openchangeclient tries to load the default one: $HOME/.open- change/profiles.ldb --profile=PROFILE -p Set the profile to use. If a profile is not specified, and one of the profiles has been set as the default in the profile database (for example, using mapiprofile -S), then that default profile will be used. --password -P Specify the password for the profile to be used. This can be omitted if the password is stored in the profile. --pf Perform operations against the Public Folders store, rather than the normal operations against a user's private folders. --folder Specify the folder name we want to work with want to open. This option is mandatory for public folders, but can also be used to open specific folders in the mailbox store. --attachments="ATTACHMENT1;ATTACHMENT2" -A Set attachments to send when sending a mail. Attached filenames need to be separated with semi-colons as specified in the descrip- tion above. This is only meaningful with --sendmail --subject=STRING -s Specify the mail subject. If no subject is specified, the mail subject will be empty. This is only meaningful with --sendmail --body=STRING -B Set the body of the mail to be the UTF8 text only content specified on the command line. This is only meaningful with --sendmail --html-inline=STRING -I Set the body of the mail to be the HTML content specified on command line. This is only meaningful with --sendmail --html-file=FILENAME -W Set the body of the mail to be the content of the specified file. This is only meaningful with --sendmail --to="USERNAME1,USERNAME2" -t Specify To recipients for the mail. Usernames need to be separated with commas as specified in the example above. This is only mean- ingful with --sendmail --cc="USERNAME1,USERNAME2" -c Specify Cc recipients for the mail. Usernames need to be separated with commas as specified in the example above. This is only mean- ingful with --sendmail --bcc="USERNAME1,USERNAME2" -b Specify Bcc recipients for the mail. Usernames need to be separated with commas as specified in the example above. This is only meaningful with --sendmail --location=STRING Specify the appointment location. This is only meaningful with --sendappointment --dtstart=STRING Specify the start date of an event. The following date format needs to be used: %Y-%m-%d %H:%M:%S e.g: 2007-06-01 14:59:00. This is only meaningful with --sendappointment and --sendtask --dtend=STRING Specify either the end date or due date of an event. The following date format needs to be used: %Y-%m-%d %H:%M:%S e.g: 2007-06-01 14:59:00 When no dtend parameter is specified, default value is set to dtstart This is only meaningful with --sendappointment and --sendtask --force Add appointment to the calendar, even if it would overlap with an existing appointment. This is only meaningful with --sendappoint- ment --private Mark the appointment as private event. This is only meaningful with --sendappointment --busystatus=STRING Set the busy status of an appointment. Possible values are FREE, TENTATIVE, BUSY or OUTOFOFFICE. This is only meaningful with --sendappointment --label=STRING Set the type of appointment. Possible values are NONE, IMPORTANT, BUSINESS, PERSONAL, VACATION, MUST_ATTEND, TRAVEL_REQUIRED, NEEDS_PREPARATION, BIRTHDAY, ANNIVERSARY and PHONE_CALL. This is only meaningful with --sendappointment --taskstatus=STRING Set the status of a task. Possible values are NOTSTARTED, PROGRESS, COMPLETED, WAITING, DEFERRED. This is only meaningful with --sendtask --fullname=STRING Set the full name in a contact message. This is only meaningful with --sendcontact --cardname=STRING Set the card name of a task or contact message. This is only meaningful with --sendcontact or --sendtask --email=STRING Set the email address in a contact message. This is only meaningful with --sendcontact --importance=STRING Set the relative importance of a task. Possible values are LOW, NORMAL and HIGH. This is only meaningful with --sendtask --color=STRING Set the color of the note. The default color is Yellow. Other options are Blue, Green, Pink and White. This is only meaningful with --sendnote --folder-name=STRING Set the folder name to create. This is only meaningful with --mkdir or --rmdir --folder-comment=STRING Set the folder comment. This is only meaningful with --mkdir --update=STRING -u Change (update) an existing item, rather than creating a new one. This is only meaningful with --sendtask , --sendnote , --sendap- pointment and --sendcontact --ocpf-file=STRING Specify the file to load OCPF data from. This is only meaningful with --ocpf-sender and --ocpf-syntax --dump-data Display raw format data associated with the operation. You normally only need this when debugging. --debug-level=LEVEL Display debugging information at the specified level (or higher). Level 10 is a lot of debug information. EXAMPLES
Fetching emails: openchangeclient --database=/tmp/profiles.ldb --profile=2000 --fetchmail Fetch emails and store attachments: openchangeclient --database=/tmp/profiles.ldb --profile=2000 --fetchmail --storemail=test All attachments from any mails will be stored in the test directory. If the specified directory does not exist, it will automatically be created. Note that if the attachment name is not unique amongst all emails, some attachments may be overwritten. Send a basic email: openchangeclient --database=/tmp/profiles.ldb --profile=2000 --to="Adm,jker" --cc=Paul --bcc=Bill --subject="It is working" --body="This is a sample body" --sendmail A mail with UTF8 (text only) content will be sent with the following recipients: to = Administrator and jkerihuel cc = Paul bcc = Bill Send an inline HTML email: openchangeclient --database=/tmp/profiles.ldb --profile=2000 --to=Adm --subject="Inline HTML sample email" --html-inline="<body bgcolor=yellow><h1>My first HTML email</h1></body>" --sendmail Administrator will receive a mail with HTML body - yellow background and a title. Send a HTML mail using a file: openchangeclient --database=/tmp/profiles.ldb --profile=2000 --to=Adm --subject="HTML file email" --html-file=/tmp/myfile.html --sendmail The content of /tmp/myfile.html will be used to fill the HTML body. If the HTML file exceed a fixed size (0x4000 bytes), then PR_HTML con- tent will be sent using MAPI streams. Send email with attachments: openchangeclient --database=/tmp/profiles.ldb --profile=2000 --to=Adm --subject="Attachments" --attachments="/tmp/file1.jpg;/tmp/file2.jpg;tmp/file2.jpg" --body="These are sample attachments" --sendmail The example above will send a UTF8 body mail to Administrator and attach file1,jpg, file2.jpg and file3.jpg to the email. Display the users in the address book openchangeclient --userlist Fetch calendar items: openchangeclient --fetch-items=Appointment Fetch contact items: openchangeclient --fetch-items=Contact Fetch task items: openchangeclient --fetch-items=Task Create appointment: openchangeclient --sendappointment --dtstart="2007-06-01 22:00:00" --dtend="2007-06-01 22:35:00" --busystatus=FREE --location="Home" --subject="Check the Junk folder" Create Task: openchangeclient --sendtask --dtstart="2008-11-01 18:00:00" --cardname="openchangeclient" --importance=HIGH --taskstatus=COMPLETED --body="my new task" Create contact: openchangeclient --sendcontact --cardname="openchangeclient" --fullname="OpenChange Client 3rd" --email="openchangeclient@nonexistentdomain.com" Create folder: openchangeclient --mkdir --folder-name="openchange" --folder-comment="comment" This example will create a generic folder named openchange under the Inbox folder. Delete folder: openchangeclient --rmdir --folder-name="openchange" This example will delete the generic folder named openchange under Inbox folder. List Mailbox hierarchy: openchangeclient --mailbox Obtain free / busy status openchangeclient --pf --freebusy="test user3" AUTHOR
Julien Kerihuel <j.kerihuel at openchange dot org> OpenChange libmapi 0.9 2009-12-17 OPENCHANGECLIENT(1)
All times are GMT -4. The time now is 07:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy