by setting the charset in an iCalendar file - outlook

I'm having trouble with accents in an iCalendar. Anyone happen to know how to set the charset in this file?
charset I want to set is this: test / calendar; method = REQUEST; charset = UTF-8
Icalender file:
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-Projuris Calendário
METHOD:PUBLISH
X-WR-CALNAME:Projuris WEB (Administrador)
X-WR-TIMEZONE:America/Sao_Paulo
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:America/Sao_Paulo
TZURL:http://tzurl.org/zoneinfo/America/Sao_Paulo
X-LIC-LOCATION:America/Sao_Paulo
END:VTIMEZONE
BEGIN:VEVENT
DTSTART:20130625T010000
DTEND:20130625T010000
ORGANIZER;CN=Projuris WEB (Administrador):MAILTO:networkservice#ache.com.br
UID:496254697
COMMENT;X-COMMENTER=MAILTO:networkservice#ache.com.br
CLASS:PUBLIC
DESCRIPTION:
SUMMARY: Pasta 12
Aditamento da Inícial Ação
STATUS:CONFIRMED
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART:20130514T080000
DTEND:20130514T080000
ORGANIZER;CN=Projuris WEB (Administrador):MAILTO:networkservice#ache.com.br
UID:300843810
COMMENT;X-COMMENTER=MAILTO:networkservice#ache.com.br
CLASS:PUBLIC
DESCRIPTION:
SUMMARY: Assembléia
STATUS:CONFIRMED
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART:20130528T080000
DTEND:20130528T080000
ORGANIZER;CN=Projuris WEB (Administrador):MAILTO:networkservice#ache.com.br
UID:1152228998
COMMENT;X-COMMENTER=MAILTO:networkservice#ache.com.br
CLASS:PUBLIC
DESCRIPTION:
SUMMARY: Assembléia
STATUS:CONFIRMED
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR

You need to specify the data in the UTF8 encoding. How do you construct the file?

well have a look at the RFC5545:
3.1.4. Character Set
There is not a property parameter to declare the charset used in a
property value. The default charset for an iCalendar stream is UTF-8
as defined in [RFC3629].

Related

8ball embed command fails to launch

I am trying to re-do my bot's 8ball command, I try to use the following code
#client.command(aliases=['8ball'])
async def _8ball(ctx, *, question):
responses = ['It is certain.',
'It is decidedly so.',
'Without a doubt.',
'Yes - definitely.',
'You may rely on it.',
'As I see it, yes.',
'Most likely.',
'Outlook good.',
'Yes.',
'Signs point to yes.',
'Reply hazy, try again.',
'Ask again later.',
'No.',
'Better not tell you now.',
'Cannot predict now.',
'Concentrate and ask again.',
"Don't count on it.",
'My reply is no.',
'My sources say no.',
'Outlook not so good.',
'Very doubtful.']
responses = random.choice(responses)
embed=discord.Embed(title="8ball", description="Ask the 8ball!", color=discord.Color.dark_purple())
embed.add_field(name="Q: {question}", value="A: {responses}", inline=False)
await ctx.send(embed=embed)
But the python file refuses to launch, and returns
File "C:\Users\r00t_technologies\Documents\bot\enigmatic-peak-21114\bot_development.py", line 135
await ctx.send(embed=embed)
^
SyntaxError: 'await' outside function
Is anyone able to help me with this issue?
EDIT: Nevermind I'm just an idiot and was looking at the wrong line, sorry for the inconvienience (I am somewhat inexperienced at this)
I Dont know Why the error say await outside a function but its already in function, i Edited Your Code And i Tested it in my Bot And it works perfectly.
So Try this:
#client.command()
async def _8ball(ctx, *, question):
responses = ['It is certain.',
'It is decidedly so.',
'Without a doubt.',
'Yes - definitely.',
'You may rely on it.',
'As I see it, yes.',
'Most likely.',
'Outlook good.',
'Yes.',
'Signs point to yes.',
'Reply hazy, try again.',
'Ask again later.',
'No.',
'Better not tell you now.',
'Cannot predict now.',
'Concentrate and ask again.',
"Don't count on it.",
'My reply is no.',
'My sources say no.',
'Outlook not so good.',
'Very doubtful.']
responses = random.choice(responses)
embed=discord.Embed(title="8ball", description="Ask the 8ball!", color=discord.Color.dark_purple())
embed.add_field(name="Q: " + question, value="A:" + responses, inline=False)
await ctx.send(embed=embed)
You need to have more than one aliases in the aliases =. Try [‘8ball’, ‘8b’]

Unable to send Gmail Message with Gmail API

Using the Gmail Service to send an email, but I'm having problem with the email format which needs to be passed to Google::Apis::GmailV1::Message, I'm passing raw parameter to it in the following format
email_raw = "From: <#{#google_account}>
To: <#{send_to}>
Subject: This is the email subject
The email body text goes here"
# raw is: The entire email message in an RFC 2822 formatted and base64url encoded string.
message_to_send = Google::Apis::GmailV1::Message.new(raw: Base64.encode64(email_raw))
response = #service.send_user_message("me", message_to_send)
This fails even when I pass email_raw without base64 encoding. I'm providing valid emails but it fails with an error
Google::Apis::ClientError (invalidArgument: Recipient address required)
I've checked Sending an email with ruby gmail api v0.9 and I also found this but it uses Mail class which I could not locate in the Gmail API Ruby client library. Currently, email_raw contains \n characters but I've tested it without it and it doesn't work.
Moreover, I also want to send attachments in a message.
We can easily offload the effort of forming a standardized and formatted email to this gem. Just include the gem in your project and do this
mail = Mail.new
mail.subject = "This is the subject"
mail.to = "someperson#gmail.com"
# to add your html and plain text content, do this
mail.part content_type: 'multipart/alternative' do |part|
part.html_part = Mail::Part.new(body: email_body, content_type: 'text/html')
part.text_part = Mail::Part.new(body: email_body)
end
# to add an attachment, do this
mail.add_file(params["file"].tempfile.path)
# when you do mail.to_s it forms a raw email text string which you can supply to the raw argument of Message object
message_to_send = Google::Apis::GmailV1::Message.new(raw: mail.to_s)
# #service is an instance of Google::Apis::GmailV1::GmailService
response = #service.send_user_message("me", message_to_send)
Mind that Gmail requires base64url encoding, not base64 encoding
See documentation:
raw string (bytes format)
The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in messages.get and drafts.get responses when the format=RAW parameter is supplied.
A base64-encoded string.
I recommend you to test first with the Try this API - you can encode the message with online base64url encoders.
Then, when using Ruby, you can use the method:
Base64.urlsafe_encode64(message).
UPDATE
The problem seems to be your raw message body.
The message body should have the followind structure:
To: masroorh7#gmail.com Content-Type: multipart/alternative; boundary="000000000000f1f8eb05b18e8970" --000000000000f1f8eb05b18e8970 Content-Type: text/plain; charset="UTF-8" This is a test email --000000000000f1f8eb05b18e8970 Content-Type: text/html; charset="UTF-8" <div dir="ltr">This is a test email</div> --000000000000f1f8eb05b18e8970--
base64url encoded, this will look like:
encodedMessage = "VG86IG1hc3Jvb3JoN0BnbWFpbC5jb20NCkNvbnRlbnQtVHlwZTogbXVsdGlwYXJ0L2FsdGVybmF0aXZlOyBib3VuZGFyeT0iMDAwMDAwMDAwMDAwZjFmOGViMDViMThlODk3MCINCg0KLS0wMDAwMDAwMDAwMDBmMWY4ZWIwNWIxOGU4OTcwDQpDb250ZW50LVR5cGU6IHRleHQvcGxhaW47IGNoYXJzZXQ9IlVURi04Ig0KDQpUaGlzIGlzIGEgdGVzdCBlbWFpbA0KDQotLTAwMDAwMDAwMDAwMGYxZjhlYjA1YjE4ZTg5NzANCkNvbnRlbnQtVHlwZTogdGV4dC9odG1sOyBjaGFyc2V0PSJVVEYtOCINCg0KPGRpdiBkaXI9Imx0ciI-VGhpcyBpcyBhIHRlc3QgZW1haWw8L2Rpdj4NCg0KLS0wMDAwMDAwMDAwMDBmMWY4ZWIwNWIxOGU4OTcwLS0"
Thus, your message body should be:
Google::Apis::GmailV1::Message.new(raw:encodedMessage)

Outlook uses the email subject as event title when sending calendar invite using ics attachment on Visualforce Email Template

I'm trying to send a calendar invite using VF template and using ICS attachment for the same but Event title uses Email subject and not the value I'm providing.
This runs perfectly on Gmail where Event title displays the value I'm providing but not on outlook.
Note: Other fields like location etc. is displayed correctly.
<messaging:emailTemplate subject="New Event" recipientType="User"
relatedToType="Sales_Team__c">
<messaging:htmlEmailBody >
<b>Internal Comments</b><br/>
</messaging:htmlEmailBody>
<messaging:attachment filename="reminder.ics" inline="true"
renderAs="text/calendar; method=REQUEST">BEGIN:VCALENDAR
METHOD:REQUEST
VERSION:2.0
PRODID::****
BEGIN:VEVENT
DTSTAMP:<apex:outputText value="{0,date,yyyyMMdd'T'HHmmss}"><apex:param
value="{!NOW()}"/></apex:outputText>Z
UID:{!JSENCODE(relatedTo.Cases__r.Name)}
DTSTART:<apex:outputText value="{0,date,yyyyMMdd'T'HHmmss}"><apex:param
value="{!relatedTo.Cases__r.Start_Date_Time__c}"/></apex:outputText>Z
DTEND:<apex:outputText value="{0,date,yyyyMMdd'T'HHmmss}"><apex:param
value="{!relatedTo.Cases__r.Start_Date_Time__c + (60/(24*60))}"/>
</apex:outputText>Z
SUMMARY:AnyText
LOCATION:{!JSENCODE(relatedTo.Cases__r.HId__r.Name)}
STATUS:CONFIRMED
BEGIN:VALARM
TRIGGER:-P1D
ACTION:DISPLAY
DESCRIPTION:Reminder
END:VALARM
END:VEVENT
END:VCALENDAR
</messaging:attachment>
</messaging:emailTemplate>
I expect invite on calendar and mail to display 'AnyText' (value in summary field) but it displays 'New Event' (email subject)
SUMMARY:<apex:outputText value="Interview with X"/>
type what you want to display in value.

Google calendar API ruby, datetime timezone

I have this code. which creates a event in my google calendar.
client = Signet::OAuth2::Client.new(client_options)
client.update!(session[:authorization])
service = Google::Apis::CalendarV3::CalendarService.new
service.authorization = client
event = Google::Apis::CalendarV3::Event.new({
start: Google::Apis::CalendarV3::EventDateTime.new(
date_time: cf_event.starts_at.to_datetime.rfc3339,
time_zone: 'America/Monterrey'
),
end: Google::Apis::CalendarV3::EventDateTime.new(
date_time: cf_event.ends_at.to_datetime.rfc3339,
time_zone: 'America/Monterrey'
),
summary: cf_event.title
})
It is a basic example my cf_event object has the starts_at attr, which is a timeWithZone.
so i had to do cf_event.starts_at.to_datetime.rfc3339.
Output
"2019-03-15T17:50:00+00:00"
The problem is, that the code creates, the event but with -6 hours.
If i go to google calendars my event it´s the day 15 at (11 - 11:50), and not (17 - 17:50)
what am i doing wrong?
You are inputting the time as 17:50:00 in UTC+0 (the +00:00 from your date_time stands for UTC or UTC+0), however, you specified a time_zone where you used Monterrey which follows the time zone UTC-6.
My guess here is that, your code takes 17:50:00 in UTC+0 then converts it to Monterrey time zone UTC-6 which results to 11:50:00. Either try removing the +00:00 or try making it -06:00.

Ruby send email with an attachment with /usr/sbin/sendmail

I am trying to send an email with a csv file for attachement.
I do the following but I only receive an email with a empty csv file (and not with the content of it). Can you please help me on that?
I don't want to use any extra library so please don't tell me to use pony or so ;-)
to="me#exemple.com"
subject='The subject'
from='"Name" <you#exemple.com>'
description ="Desc"
csvnamefile = "/path/to/file/filename.csv"
puts value = %x[/usr/sbin/sendmail #{to} << EOF
subject: #{subject}
from: #{from}
Content-Description: "#{csvnamefile}"
Content-Type: multipart/mixed; name="#{csvnamefile}"
Content-Transfer-Encoding:base64
Content-Disposition: attachment; filename="#{csvnamefile}"
Description : #{description}
EOF]
Thanks
Thanks Alex. I could make it work with your informations.
The final working result looks like this:
binary = File.read(csvnamefile)
encoded = [binary].pack("m") # base64 econding
puts value = %x[/usr/sbin/sendmail #{to} << EOF
subject: #{subject}
from: #{from}
Content-Description: "#{csvnamefile}"
Content-Type: text/csv; name="#{csvnamefile}"
Content-Transfer-Encoding:base64
Content-Disposition: attachment; filename="#{csvnamefile}"
#{encoded}
EOF]
/usr/sbin/sendmail doesn't know anything about attachments and treats email message body according to RFC 5322 as flat US-ASCII text. To send a file as attachment you need to format your message as MIME message according to RFC 2045. For example of such a message see Appendix A to RFC 2049.

Resources