how to generate barcode in c# net with example Additional Arguments Passed to the Mailer, in app/controllers/ events_controller.rb in Font

Printer QR Code in Font Additional Arguments Passed to the Mailer, in app/controllers/ events_controller.rb

Listing 8-8. Additional Arguments Passed to the Mailer, in app/controllers/ events_controller.rb
QR Code ISO/IEC18004 Printer In None
Using Barcode creator for Font Control to generate, create QR Code JIS X 0510 image in Font applications.
www.OnBarcode.com
Making ANSI/AIM Code 39 In None
Using Barcode printer for Font Control to generate, create Code-39 image in Font applications.
www.OnBarcode.com
def invite_friend event = Event.find(params[:id]) EventMailer.deliver_email_friend(params[:email], params[:name], event) flash[:notice] = 'Your friend has been notified about this event' redirect_to event_url(event) end
QR Printer In None
Using Barcode creation for Font Control to generate, create Quick Response Code image in Font applications.
www.OnBarcode.com
Painting Barcode In None
Using Barcode printer for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
Finally, we need to update the email template. We want to give it some HTML formatting and make sure it uses the new variables we ve set up: @sender_name and @event. The modified template, located in app/views/event_mailer/email_friend.rhtml, should look like Listing 8-9.
Printing Barcode In None
Using Barcode encoder for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
Data Matrix 2d Barcode Generator In None
Using Barcode drawer for Font Control to generate, create Data Matrix 2d barcode image in Font applications.
www.OnBarcode.com
Listing 8-9. HTML email_friend Template, in app/views/ event_mailer/email_friend.rhtml
PDF-417 2d Barcode Creator In None
Using Barcode printer for Font Control to generate, create PDF-417 2d barcode image in Font applications.
www.OnBarcode.com
British Royal Mail 4-State Customer Code Drawer In None
Using Barcode generation for Font Control to generate, create Royal Mail Barcode image in Font applications.
www.OnBarcode.com
<html> <body> <p> One of your friends, <%= @sender_name %>, thinks you'll like an event we have listed. </p> <p> Come check all the information about <%= @event.title %> at <%= url_for :only_path => false, :host => "eventalicio.us", :controller => "events", :action => "show", :id => @event %> </p> </body> </html>
Draw QR Code ISO/IEC18004 In Java
Using Barcode maker for Java Control to generate, create QR Code JIS X 0510 image in Java applications.
www.OnBarcode.com
QR Maker In C#
Using Barcode encoder for .NET framework Control to generate, create QR image in VS .NET applications.
www.OnBarcode.com
CHAPTER 8 SENDING AND RECEIVING MAIL
USS Code 128 Printer In None
Using Barcode encoder for Online Control to generate, create Code 128 Code Set C image in Online applications.
www.OnBarcode.com
UCC.EAN - 128 Creation In Objective-C
Using Barcode generator for iPhone Control to generate, create UCC.EAN - 128 image in iPhone applications.
www.OnBarcode.com
Let s see the new version of our email. With your application running, go to an event details page and send yourself an invite again. The message you receive should look something like the one shown in Figure 8-2.
Encode Data Matrix ECC200 In Visual Basic .NET
Using Barcode printer for VS .NET Control to generate, create Data Matrix ECC200 image in VS .NET applications.
www.OnBarcode.com
Print Code 39 Extended In None
Using Barcode maker for Online Control to generate, create Code 3 of 9 image in Online applications.
www.OnBarcode.com
Figure 8-2. Email received in HTML format
DataMatrix Encoder In Objective-C
Using Barcode maker for iPad Control to generate, create Data Matrix image in iPad applications.
www.OnBarcode.com
Painting PDF417 In None
Using Barcode encoder for Microsoft Word Control to generate, create PDF 417 image in Office Word applications.
www.OnBarcode.com
That looks pretty good. But what if our users don t have a rich email client and can t read HTML mail We can work around this by sending both HTML and plain text, which is what we ll show you how to do next.
PDF 417 Encoder In VS .NET
Using Barcode creation for ASP.NET Control to generate, create PDF-417 2d barcode image in ASP.NET applications.
www.OnBarcode.com
UPC A Creation In .NET Framework
Using Barcode printer for Reporting Service Control to generate, create GS1 - 12 image in Reporting Service applications.
www.OnBarcode.com
Adding Multiple Parts to Messages
UPC Symbol Maker In None
Using Barcode printer for Online Control to generate, create UPC-A image in Online applications.
www.OnBarcode.com
Linear Printer In Visual Studio .NET
Using Barcode creation for ASP.NET Control to generate, create Linear image in ASP.NET applications.
www.OnBarcode.com
When you add different parts to an email that represent the same message, the email client will recognize that there are alternatives for the same message, and it will choose the most appropriate part based on the environment or the user preferences. Fortunately, Action Mailer makes this ridiculously easy: simply include the name of the content type as part of the template name using the following format:
#{action_name}.#{content_type}.rhtml
So, if we create a plain-text representation of our mailer template called
email_friend.text.plain.rhtml, and rename our existing HTML template to email_friend.text.html.rhtml, Action Mailer will automatically create a multiple-part
message for each part. Let s go ahead and do that now. First, rename email_friend.rhtml to email_friend.text.html.rhtml, and create a plain text representation in a file called email_friend.text.plain.rhtml with the code shown in Listing 8-10.
CHAPTER 8 SENDING AND RECEIVING MAIL
Listing 8-10. Plain Text email_friend Template, in app/views/event_mailer/email_friend.text.plain.rhtml
One of your friends, <%= @sender_name %>, thinks you'll like an event we have listed. Come check all the information about <%= @event.title %> at <%= url_for :only_path => false, :host => "eventalicio.us", :controller => "events", :action => "show", :id => @event %>
Adding Attachments
In some cases, you might want to add attachments to an email message. Action Mailer makes this a straightforward task by providing the attachment helper. You simply tell attachment which file you want to attach to the email. Let s walk through an example of attaching a file to an email message. Assume that we want to send a logo image of our event application every time a user sends an email about an event to a friend. Just for demonstration, we ll use the default Rails logo, which should be in the public/images directory, a vestige of the Welcome to Rails index.html file we deleted back in 6. To attach this image file to the email we created in the previous section, add a call to the attachment helper in the email_friend method in the EventMailer class, as shown in Listing 8-11.
Listing 8-11. Adding an Attachment to the Mailer, in app/models/event_mailer.rb
def email_friend(recipient, sender_name, event) @subject = '[Eventalicious] Check out this great event' @from = 'Eventalicious <events@example.com>' @recipients = recipient @content_type = 'text/html' @body = { :sender_name => sender_name, :event => event } attachment "image/png" do |a| a.body = File.read("public/images/rails.png") a.filename = "event-a-licious.png" end end
CHAPTER 8 SENDING AND RECEIVING MAIL
When we call the attachment helper, first we identify the content type of the file we want to attach, which is "image/png". In the given block, we indicate the file we re attaching using the body property, and the filename we want the recipient to see using the filename property.
You can specify the body of an attachment by using the File.read method if the file you re sending Tip exists on disk. Alternatively, you can generate the file on the fly if it s a dynamic file, like a personalized PDF or Word document. Just set the correct content type (such as application/pdf) and pass the results of your attachment generation to the body method.
Copyright © OnBarcode.com . All rights reserved.