C
CParticle
I'm trying to create a new mime message via imap but I'm having some
problems getting the formatting down.
I'm using net/imap and rmail to get and put data onto the imap
server. I'd like to set the header correctly so that I can write the
data to the server such that it understand what it is. In this case a
calendar item. The idea being that I could then write a calendar item
directly to my calendar on my exchange server and exchange would treat
it as such.
---Begin Code-----
require 'net/imap'
require 'rubygems'
require 'rmail'
imap = Net::IMAP.new('myserver')
imap.login('username', 'password')
imap.select('Calendar-folder')
myAppt = RMail::Message.new
myAppt.header.date = Time.now
myAppt.header.from = '(e-mail address removed)'
myAppt.header.to = '(e-mail address removed)'
myAppt.header.subject = 'Ruby test appointment'
myAppt.header.add('Content-Type', 'MULTIPART/ALTERNATIVE')
part = RMail::Message.new
part.header.add('Content-Type', 'TEXT/CALENDAR', nil, 'param' =>
'{"METHOD" => "REQUEST"}')
part.header.add('Content-class', 'urn:content-classes:appointment')
part.body = vCard
myAppt.add_part(part)
imap.append("Calendar-folder", RMail::Serialize.write('', myAppt),
[:Seen])
---End Code-----
I'm particularly concerned with how to get the param set properly.
----------------------------------------------
I pulled some data from the server using imap.fetch(message_id,
"BODY")
This is what I would like to get the header to look like
#<struct Net::IMAP::FetchData seqno=1, attr={"BODY"=>#<struct
Net::IMAP::BodyTypeMultipart media_type="MULTIPART",
subtype="ALTERNATIVE", parts=[#<struct Net::IMAP::BodyTypeText
media_type="TEXT", subtype="CALENDAR", param={"METHOD"=>"REQUEST"},
content_id=nil, description=nil, encoding="8BIT", size=1279, lines=22,
md5=nil, disposition=nil, language=nil, extension=nil>], param=nil,
disposition=nil, language=nil, extension=nil>}>
---------------------------------------------
This is what I'm managing to create
#<struct Net::IMAP::FetchData seqno=4, attr={"FLAGS"=>[:Seen],
"BODY"=>#<struct Net::IMAP::BodyTypeMultipart media_type="MULTIPART",
subtype="ALTERNATIVE", parts=[#<struct Net::IMAP::BodyTypeText
media_type="TEXT", subtype="CALENDAR", param={"PARAM"=>"{"},
content_id=nil, description=nil, encoding="7BIT", size=1761, lines=30,
md5=nil, disposition=nil, language=nil, extension=nil>], param=nil,
disposition=nil, language=nil, extension=nil>}>
Thanks for any help you can give.
CParticle
problems getting the formatting down.
I'm using net/imap and rmail to get and put data onto the imap
server. I'd like to set the header correctly so that I can write the
data to the server such that it understand what it is. In this case a
calendar item. The idea being that I could then write a calendar item
directly to my calendar on my exchange server and exchange would treat
it as such.
---Begin Code-----
require 'net/imap'
require 'rubygems'
require 'rmail'
imap = Net::IMAP.new('myserver')
imap.login('username', 'password')
imap.select('Calendar-folder')
myAppt = RMail::Message.new
myAppt.header.date = Time.now
myAppt.header.from = '(e-mail address removed)'
myAppt.header.to = '(e-mail address removed)'
myAppt.header.subject = 'Ruby test appointment'
myAppt.header.add('Content-Type', 'MULTIPART/ALTERNATIVE')
part = RMail::Message.new
part.header.add('Content-Type', 'TEXT/CALENDAR', nil, 'param' =>
'{"METHOD" => "REQUEST"}')
part.header.add('Content-class', 'urn:content-classes:appointment')
part.body = vCard
myAppt.add_part(part)
imap.append("Calendar-folder", RMail::Serialize.write('', myAppt),
[:Seen])
---End Code-----
I'm particularly concerned with how to get the param set properly.
----------------------------------------------
I pulled some data from the server using imap.fetch(message_id,
"BODY")
This is what I would like to get the header to look like
#<struct Net::IMAP::FetchData seqno=1, attr={"BODY"=>#<struct
Net::IMAP::BodyTypeMultipart media_type="MULTIPART",
subtype="ALTERNATIVE", parts=[#<struct Net::IMAP::BodyTypeText
media_type="TEXT", subtype="CALENDAR", param={"METHOD"=>"REQUEST"},
content_id=nil, description=nil, encoding="8BIT", size=1279, lines=22,
md5=nil, disposition=nil, language=nil, extension=nil>], param=nil,
disposition=nil, language=nil, extension=nil>}>
---------------------------------------------
This is what I'm managing to create
#<struct Net::IMAP::FetchData seqno=4, attr={"FLAGS"=>[:Seen],
"BODY"=>#<struct Net::IMAP::BodyTypeMultipart media_type="MULTIPART",
subtype="ALTERNATIVE", parts=[#<struct Net::IMAP::BodyTypeText
media_type="TEXT", subtype="CALENDAR", param={"PARAM"=>"{"},
content_id=nil, description=nil, encoding="7BIT", size=1761, lines=30,
md5=nil, disposition=nil, language=nil, extension=nil>], param=nil,
disposition=nil, language=nil, extension=nil>}>
Thanks for any help you can give.
CParticle