How to send SQL script results as a table in email body via Automic - sql

I have a workflow which looks like below.
The first task of this workflow runs a simple select * query and the next one sends an email. They are working fine individually. What I want is to send the output of the SQL task as an input to the email task so that it can be attached to the email being sent.
I have tried to manually enter the runId of the SQL task in below field of notification object and it works as expected. But how to make this field take dynamic value from its predecessor instead of a hardcoded one?
Also, is there a way I can include the output of the select * in the email body as a table ?
Update --1
I was able to get a hold of runId of preceding task via the below script. Now only need help with including it in the mail body as opposed to attachement.
:SET &NR# = SYS_ACT_PREV_NR()
:PRINT "RunID of the previous task is &NR#."

Firstly;
Setup
The package is loaded by running the following scripts.
sys/passwordord AS SYSDBA
#$ORACLE_HOME/rdbms/admin/utlmail.sql
#$ORACLE_HOME/rdbms/admin/prvtmail.plb
In addition the SMTP_OUT_SERVER parameter must be set to identify the SMTP server.
CONN sys/password AS SYSDBA
ALTER SYSTEM SET smtp_out_server='smtp.domain.com' SCOPE=SPFILE;
-- Instance restart only necessary in 10gR1.
SHUTDOWN IMMEDIATE
STARTUP
I would suggest you use a mail relay on the database server, rather than connecting directly to an external mail server. The mail relay configuration can be simple, with a reference to "localhost" in the SMTP_OUT_SERVER parameter. Any complexities about connecting to your external mail server are then hidden in the mail relay configuration.
Send Emails
With the configuration complete we can now send a mail using the SEND procedure. It accepts the following parameters.
SENDER : This should be a valid email address.
RECIPIENTS : A comma-separated list of email addresses.
CC : An optional comma-separated list of email addresses.
BCC : An optional comma-separated list of email addresses.
SUBJECT : The subject line for the email.
MESSAGE : The email body.
MIME_TYPE : Set to 'text/plain; charset=us-ascii' by default.
PRIORITY : (1-5) Set to 3 by default.
REPLYTO : Introduced in 11gR2. A valid email address.
Below is an example of the usage.
BEGIN
UTL_MAIL.send(sender => 'me#domain.com',
recipients => 'person1#domain.com,person2#domain.com',
cc => 'person3#domain.com',
bcc => 'myboss#domain.com',
subject => 'UTL_MAIL Test',
message => 'If you get this message it worked!');
END;
/
Send Emails with Attachments
The package also supports sending mails with RAW and VARCHAR2 attachments using the SEND_ATTACH_RAW and SEND_ATTACH_VARCHAR2 packages respectively. They work in a similar fashion to the SEND procedure, with a few extra parameters.
ATTACHMENT : The contents of the attachment. This should be VARCHAR2 or RAW depending on which procedure you call.
ATT_INLINE : Indicates if the attachment should be readable inline. Default FALSE.
ATT_MIME_TYPE : The default is 'text/plain; charset=us-ascii'.
ATT_FILENAME : The name for the attachment.
Below is an example of sending an email with a text attachment.
BEGIN
UTL_MAIL.send_attach_varchar2 (
sender => 'me#domain.com',
recipients => 'person1#domain.com,person2#domain.com',
cc => 'person3#domain.com',
bcc => 'myboss#domain.com',
subject => 'UTL_MAIL Test',
message => 'If you get this message it worked!',
attachment => 'The is the contents of the attachment.',
att_filename => 'my_attachment.txt'
);
END;
/

Related

Exim replace empty Subject

How to add "(No Subject)" automatically in emails sending with the subject is empty. My external smtp require a subject to send e-mails and display the error in this case:
SMTP<< 5.2.1 Subject is Mandatory

How to handle space in recipient address

I am trying to send email using NodeMailer Node module and IBM Domino server.
I need to send email to a recipient Domino Administrator/test#test but the space in address creates issue.
Because of space in address, Server return error as it considers recipient as Administrator/test#test which does not exists.
Router: Unable to deliver message 0023B889 to Administrator/test#test.
I tried adding ascii characters for space, tried surrounding by extra quotes but nothing worked.
I am initializing mail options in Nodemailer like this
var mailOptions = {
from: 'Domino Administrator/test',
to: 'Domino Administrator/test#test',
subject: 'Sending mail domino 2',
text: 'That was easy!'
};
Any idea how to handle space ? or any changes needs to be done at Domino server side ?
Taking hint from some RFC , I was able to sort this issue by adding '_'. So the code works if recipient address is to: 'Domino_Administrator/test#test'

How to create virtual email addresses with mailrule iredmail

I have been asked to create special mailbox with theese functions:
1) Create new mailbox test#domain.com (SMTP, POP3).
2) Incomming messages:
Arrange that this mailbox will recieve messages to virtual email addresses in test.xxx#domain.com form. Where xxx is any number with variable length. This is typically achieved in catch-all mailbox with regular expression mailrule (where TO or CC matches test\.\d+#domain.com)
3) Outgoing messages:
Enable login test#domain.com to send email with variable "FROM" field according to point 2) This is typically achieved by enabling any "FROM" for that mailbox.
Overall purpose of this mailbox is this:
There exists any reservation number in the system. For example 1500278.
employee sends email to client from CRM and email address test.1500278#domain.com and this email is registered in CRM.
Client replies to test.1500278#domain.com and this email is received to test#domain.com
system picks that mailbox using POP3 and assigns that email to reservation number 1500278.
so all need to know how to create this mail
the mail server running on Centos apache iRedMail
thanks for help.
done it by Memcached
and here is the link http://memcached.org/

email header "from" containing first and last names, not sender's email

I'm reading emails from pop3 server with zend mail component.
What I want is to know who is sent this email and when I try $message->from I see "FirstName LastName" without senders email.
I do print_r($message->getHeaders()) and do not see sender's email in any header from this email.
I thought that senders email is required and always must be set. Anything wrong here?
Is that possible to have email with "from" header with only First/Last name without email?
As per my comment:
if you print_r() a valid from header and the address is in angle brackets, you may only see it by viewing the HTML source, because the angle brackets and email address may be treated as an (albeit unrecognised) HTML tag, by the browser.
However, if anyone encounters this issue in the future (and the email address does not show in the HTML source), it is worth bearing in mind that the sender could have sent an email without a From: address, even though that is technically invalid.
Yes, this is totally possible. There are 2 usually "FROM" addressess with every email. 99% of the time, these are the same values, but they can be different. There is the MAIL FROM address that is used during the SMTP session, that issues the MAIL FROM command. Then, there is the FROM address found in the email message headers (this FROM address is sent during the SMTP DATA command). This is how you can get email spoofing.
Think of it this way (in the snail mail physical world). You can have a FROM address on the outside of an envelope (this would be equiv to the MAIL FROM command). This is supposed to be the person sending the message. You can then have a FROM value that is different on the letter head that is inside the envelope. This would be the FROM value you are seeing in the email headers.
Here is an example of some raw headers without a FROM address
From: "Steve James"
To: "John Doe" <you#yourcompany.com>
Date: Fri, 24 Feb 2012 07:43:40 -0800
Subject: Here is the progress report
....
Hopefully I didn't make that about as clear as mud.
--
Use the following format:
Firstname Lastname <vasya#poupkine.com>

how to process incoming mails using mailman and update them into the database

am developing ruby on rails3 application where i am sending an email to user and if user replies that email then that reply content, date should be updated to the database. For this i have ProductComment model. when admin sends comment to the user it will be stored in the database. if user replies to that then database should be updated accordingly. I am trying to use mailman. I have installed the gem. But am not getting how to get the comment id, what should i write in replyto address, where to write the mailman code and from which mail i should read.
Am sending email like this:
mail(:to => #user.email, :subject => "Edit Your Product", :reply_to=>"abc#syz.com)
I am handling it in products controller like this:
require 'mailman'
Mailman::Application.run do
to 'abc#xyz.com' do
ProductComment.create(message)
end
end
Please help me to come out from this problem
Please tell me how to use mailman gem in ruby on rails3 application
there is a recent pro-episode on receiving emails with mailman on railscasts: http://railscasts.com/episodes/313-receiving-email-with-mailman
chmod +x script/mailman_server
cat mailman_test.eml | script/mailman_server
script/mailman_server
-
# script/mailman_server
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
require "mailman"
Mailman.config.logger = Logger.new("log/mailman.log")
Mailman.config.pop3 = {
server: 'pop.gmail.com', port: 995, ssl: true,
username: ENV["GMAIL_USERNAME"],
password: ENV["GMAIL_PASSWORD"]
}
Mailman::Application.run do
default do
begin
Ticket.receive_mail(message)
rescue Exception => e
Mailman.logger.error "Exception occurred while receiving message:\n#{message}"
Mailman.logger.error [e, *e.backtrace].join("\n")
end
end
end
-
def self.receive_mail(message)
ticket_id = message.subject[/^Update (\d+)$/, 1]
if ticket_id.present? && Ticket.exists?(ticket_id)
Ticket.update(ticket_id, body: message.body.decoded)
else
Ticket.create subject: message.subject, body: message.body.decoded, from: message.from.first
end
end
Postmark Inbound is a good choice. Setup like so:
Sign up for Postmark, they will give you an email which Postmark will assign to your account.
Sign up for Google Apps branded Gmail for your domain. Set up forwarding from an account to the Postmark email address. People can now email reply#yourdamin.com, and it will be forwarded to Postmark.
Create a callback URL. When Postmark receives an email it will package it up and post it to your callback. You can then access the email attributes via the params hash.
To implement replying to messages, simply add a reply to field to your outgoing message which contains a unique hash for the message, e.g.
reply+uniquehash#yourdomain.com.
This is a legal email address, and will be sent to reply#yourdomain.com. You can then parse out the hash in your callback and use it to match the reply to the original message.
Simple :)