nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ics files with nhm / mh-e


From: Axel Jantsch
Subject: Re: ics files with nhm / mh-e
Date: Wed, 1 Jan 2020 08:05:23 +0100

Hello All,

>>>>> On Tue, 31 Dec 2019 07:47:39 -0800, Henrique Martins <address@hidden> 
>>>>> said:

    > If it is not too big, maybe post it in a reply,

Attached is the script replyics.sh that allows to reply to an ics event
invitation.
It acts differently depending on its name because in mh-e "K e" I cannot
easily hand over an argument. Hence, I have soft links for

icalaccept
icaldecline
icalshow
icaltentaive
icalcancel

If invoked on the event invitation it will use generate an ics file with
the respective response and use mhmail to send it to the event
organizer.
E.g.

icalaccept event.ics

From MH-E it can be invoked with "K e icalaccept" on the appropriate
mime part.


If there are suggestions for improving it, let me know.

Cheers,
Axel



>>>>> On Tue, 31 Dec 2019 07:47:39 -0800, Henrique Martins <address@hidden> 
>>>>> said:

    > David Levine <address@hidden> wrote:

    axel> So this works reasonably well. I am happy to share it
    axel> with anyone who is interested.

    david> I'd be interested.

    > If it is not too big, maybe post it in a reply,

    > -- Henrique


-- 
Axel Jantsch, Prof. of Systems on Chip
TU Wien
Gusshausstrasse 27-29/384, 1040 Vienna, Austria
Phone: +43 1 58801 38415
Email: address@hidden
Web: www.ict.tuwien.ac.at

#!/bin/sh

#
# replyics.sh expects an ics file as firts and only argument.
# It does different things depending on its name:
# icalshow:      Show the ics file with mhical
# icalaccept:    generate a response icf file for accepting the invitation and 
send an email reposonse to the orgnaizer.
# icaldecline:   generate a response icf file for declining the invitation and 
send an email reposonse to the orgnaizer.
# icaltentative: generate a response icf file for tentatively accepting the 
invitation and send an email reposonse to the orgnaizer.
# icalcancel:    generate a response icf file for canceling the invitation and 
send an email reposonse to the orgnaizer.


cmnd=`basename $0`

partf=calmsg.ics
responsef=response.ics
responseaddr=""

# Function for extracting the organizer's email address from the ics file:
getaddr () {
    local icalf=$1;
    addr=`awk 'BEGIN {IGNORECASE=1; }
               /^organizer/ { split($0, orgrec, "mailto:";); print orgrec[2]; }' 
$icalf`
    return
}

USAGE="$0 ICSFILE\n
       
       $0 expects exactly one argument which have to be an ics file."

#############################################################################
#############################################################################

if [ $# -ne 1 ]
then echo $USAGE;
     exit 2;
fi

prevdir=`pwd`
tmpd=$HOME/tmp/replyicstmpdir
mkdir -p $tmpd

cp $1 $tmpd/$partf

cd $tmpd


ftype=`file -b $partf |cut -f 1 -d " "`
if [ $ftype \!= "vCalendar" ]
then
    echo $USAGE; exit 2;
fi


pMail=0;
case $cmnd in
    icalshow) mhical -infile $partf |xmessage -file - ;;
    icalaccept) mhical -infile $partf -reply accept -outfile $responsef ;
               pMail=1;
               subject="Accepted"
               ;;
    icaldecline) mhical -infile $partf -reply decline -outfile $responsef ;
               pMail=1;
               subject="Declined"
               ;;
    icaltentative) mhical -infile $partf -reply tentative -outfile $responsef ;
               pMail=1;
               subject="Tentative Accept"
               ;;
    icalcancel) mhical -infile $partf -cancel -outfile $responsef ;
               pMail=1;
               subject="Canceled"
               ;;
    *) echo "Unknown command: $cmnd"; exit 2;;
esac

# Sending email:
if [ $pMail -eq 1 ]
then
    getaddr $partf; responseaddr=$addr;
    if [ "_$responseaddr" = "_" ]
    then echo "Organizer address not found in ics part."; exit 2;
    elif [ `expr $responseaddr : ".*@.*\..*"` -eq 0 ]
    then echo "Organizer address not found in ics part."; exit 2;
    fi;
    
    mhmail -to $responseaddr -attach $responsef -body " " -subject "$subject"
    # cp $responsef ../ifile.ics
fi


# Cleaning up:
rm  -f $tmpd/*
rmdir $tmpd

exit





reply via email to

[Prev in Thread] Current Thread [Next in Thread]