How to send an email with attachment using apex (PL/SQL) without storing the attachment in server - oracle-sqldeveloper

I wanted to send an email with attachment from the oracle apex workspace, currently i am using the APEX_MAIL package which includes (APEX_ATTACHMENT, APEX_EXPORT functions). But the issue is, we are creating an CSV file and adding it as a mail attachment while sending the email and the attachments are sometimes larger in size which are getting stored in server each time the mail is triggered. This issue is causing a regular maintenance for the DBA to clear the data in the server.
Can anyone suggest is there any alternative for the current approach in order to come out of the issue.
Thanks in advance.
I tried oracle APEX_MAIL but the attachment is saving in database, please provide the alternate approach for the solution.

If you are generating the attachment CSV in the procedure as a BLOB variable, you can use it as described here. The only difference would be you should send your blob variable for p_attachment parameter.
For example:
apex_mail.add_attachment(
p_mail_id => l_id,
p_attachment => v_CSV, --the CSV file that you generated and assigned to a variable of type BLOB
p_filename => l_filename,
p_mime_type => l_mime_type,
p_content_id => l_content_id );
If you do not generate the CSV file in the package yourself, another approach would be using an intermediate table where you save your attachment file and having a scheduled job that clears that intermediate table on a specified basis. (You can clear the table after the mail is sent but for the logging/reporting it would be better to keep the attachments for a while I believe).

Related

How to send emails with attachments located on disc using PL/SQL?

I have a ready script which sends email using PL/SQL. It has been stored in a procedure and when it is called by passing proper parameters, it sends email.
Now, I need to pick up a file from the disc and send it as an attachment. I have seen many examples where the data is stored in BLOB and comes from the DB. In my case it is not from DB instead it is a file on the server/disc.
How to achieve this ?
Use UTL_FILE to read data from disk.
You can find a good example of how to use it to load an entire file into a BLOB in the Alexandria PL/SQL Library. Look at (or just copy!) the code from file_util_pkg.get_blob_from_file.
ORACLE DIRECTORIES can be used to achieve this.
link to a full email/smtp example

Assigning and accessing custom email headers in .NET

I need to add a custom header to an email using the System.Net.Mail.MailMessage class and then using the Microsoft.Exchange.WebServices.Data.EmailMessage class I need to read that value.
What I'm trying to do exactly is bounce processing for emails we send out. I am generating a new Guid value and adding it to the headers right before it's sent. I'm storing that value in a database and need to match it up when a separate process scans the inbox for processing. I all of that working except one part - I can't get the message ID from the header.
I know messages have a Message-ID header (which is automatically added) and I can access that but what I'm having difficulty with is getting that value when it's sent in the first place. Is that even possible? If so I'll use that instead of my own value.
I can get the email address and the other relevant information but the system I've written uses the message ID I was assigning as the foreign key used in joins in the database.
Any guidance on this would be appreciated. I doubt I'm the only person whose ever tried doing this.
Sorry everyone, the email I was testing with didn't have the header in it, that's why it couldn't be found.
I created a new email with it added and I could access it through the InternetMessageHeaders property of the EmailMessage object.

Bulk email with multiple attachment using SMTP

I need a program that will be used to send email using SMTP from a local machine. I need to send about 2000 emails.
The emails addresses are located in a MS Excel document with unique ID numbers. The attachments are in a separate folder with unique ID numbers same as the excel folder.
Every recipient will receive the same email with different attachment according to the ID number.
Is there any free or low cost program available out there that will achieve the goal?
If not, what is the best and quickest way to write a program like this?
Example of MS Excel Data:
DWEL1859 jack#bla.com
DSYD1514 caleb#bla.com
DSYD1738 jen#bla.com
DNSW2736 shown#bla.com
DPRE2510 roger#bla.com
Example of zip file names:
DNSW2736.zip
DPRE2510.zip
DSYD1514.zip
DSYD1738.zip
DWEL1859.zip
Use PHPMailer with couple of any DB server (i.e. MySQL) and PHP script containing some trivial logic. Write me on email (see accaunt) if you will need help within realization.

Mirth losing data in mapper variables

I have a database reader channel set up that actually reads the database at 10 second intervals and sends to a web service just fine. We get a valid response from the wsdl.
However, I need to update the database record so that it is flagged as having been processed. in this case we are simple changing a field from 100 to 101. However, when I try to update the field OR send an email containing ANY data that has been stored into mapper variables I get nothing. The database does not update. Emails send blanks for fields.
When I go into the channel messages for processed messages I can see good data in the Raw Message and Encoded Message tabs. There are no values in the Mappings tab.
Any suggestions on troubleshooting?
The Run-on-Update statement does not have access to the channel map, as it runs after message Encoding (and even the post-processor, I believe).
It DOES have access to the globalChannelMap and the responseMap. Put your new ID in the globalChannelMap and you should be good to go.
If you also want to send an email, would recommend you instead add an SMTP Writer destination (e.g., SMTP writer), which will have access to any channelMap variables created in a 'Destination 1'; as well as the globalChannelMap.

Do Salesforce VF email templates require related object to be persisted?

When a new lead comes in, I want to use a before trigger and a Visualforce email template that contains lead field values to send an email using the SingleEmailMessage class. The email is being generated, but all of the lead fields are null even though (known via System.Debug) they do have values going into the call.
Since I'm passing the still-unsaved lead Id via the mail.setWhatId(lead.Id) method, I'm beginning to think that the mail class is using the Id value and trying to do a database look-up rather than as a reference to the still unsaved lead in memory.
Does anyone know if that's the case? My class works flawlessly when the lead already exists.
If it is the case that the Apex mail class does a DB read, any pattern suggestions for the case where one needs to send and email and update a lead field value before the lead is saved? I can't use the Workflow email notification because the email is being addressed to customers, and there's some additional Apex code that sorts out what address to fetch from existing Account records based on some Lead fields--hence I think the need for using VF email templates in the first place.
setWhatId (and pretty much any method that takes an ID value as an argument) definitely does expect the row to be persisted already. To get around this, you should be able to just do your field update in the before trigger, and add an after trigger to send the email.