String csvHeader = 'AccountId, Latest Opp \n'; string mainContent = csvHeader; Map opps = new Map(); for(Opportunity op: [select AccountId, Billing_Frequency__c,Customer_Type__c , closedate from Opportunity where closedate >2019-03-01 and closedate <2020-03-31 and StageName='Closed Won' order by closedate asc]){ opps.put(op.AccountId, op); } for (Id oid : opps.keySet()) { mainContent+= oid+','+opps.get(oid).Id+'\n'; } Messaging.SingleEmailMessage singEmail = new Messaging.SingleEmailMessage (); String [] toAddresses = new list {'ayub.salsforce@gmail.com'}; //Set recipient list singEmail.setToAddresses (toAddresses); String subject = 'Retroactively Created Agreements'; singEmail.setSubject (subject); singEmail.setPlainTextBody (mainContent); Messaging.SendEmailResult [] r = Messaging.sendEmail (new Messaging.SingleEmailMessage [] {singEmail});
175 thoughts on “Generate CSV using apex and email as attachment”
Comments are closed.
I constantly spent my half an hour to read
this website’s posts everyday along with a mug of coffee.
Aw, this was a very nice post. Taking a few minutes and actual
effort to produce a very good article… but what can I
say… I hesitate a lot and never seem to get nearly anything done.
Saya akan segera rebut rss Anda karena saya tidak bisa
Saya yakin artikel ini telah menyentuh semua pengguna internet, benar-benar
bagus pos tentang membangun web site baru.
Feel free to surf to my page Peliculas 123 joker
magnificent post, very informative. I ponder why the opposite experts of this sector
don’t notice this. You must proceed your writing.
I’m confident, you have a huge readers’ base already!
My web-site … shaboxes.com
Now I am ready to do my breakfast, afterward having my
breakfast coming again to read other news.
Thanks for ones marvelous posting! I truly enjoyed
reading it, you may be a great author. I will make certain to bookmark your blog and will come
back someday. I want to encourage you to definitely continue
your great job, have a nice day!
I went over this website and I think you have a lot of great info, saved to favorites (:.
Here is my web-site funkyfreeads.com
Pretty part of content. I simply stumbled upon your website and in accession capital
to claim that I acquire in fact enjoyed account your weblog posts.
Any way I’ll be subscribing in your feeds and even I achievement you get
right of entry to constantly fast.
Here is my web page … backpageladies.com
This article will assist the internet viewers for creating new webpage or even a blog from start
to end.
Here is my website geegram.net
I just like the helpful information you provide in your articles.
I will bookmark your blog and take a look at once more right here frequently.
I’m reasonably certain I will learn many new stuff right right here!
Good luck for the following!
Here is my page … litdevelopments.com
This information is priceless. How can I find out more?
Aw, this was an extremely good post. Finding the time and actual effort to create a good article… but what can I say… I
hesitate a whole lot and never seem to get anything done.
Howdy fantastic website! Does running a blog like this require a massive amount work?
I have no knowledge of programming however I had been hoping to start my own blog soon. Anyhow, should
you have any ideas or tips for new blog owners
please share. I understand this is off topic nevertheless I just wanted to ask.
Thanks!
Hi there, I discovered your blog by way of Google even as searching for a comparable subject, your website got here up, it seems
to be good. I have bookmarked it in my google bookmarks.
Hello there, simply was alert to your weblog thru Google, and located that it’s really informative.
I’m going to be careful for brussels. I’ll be grateful if you continue this in future.
Numerous folks will likely be benefited out of your writing.
Cheers!
Howdy, i read your blog occasionally and i own a similar one and i
was just curious if you get a lot of spam comments? If so how
do you protect against it, any plugin or anything you can recommend?
I get so much lately it’s driving me insane so any help is very much appreciated.
Here is my site: http://www.fivedollarclassifieds.com
Thanks for the sensible critique. Me & my neighbor were
just preparing to do some research on this. We got a grab a book from
our area library but I think I learned more from this post.
I am very glad to see such fantastic information being shared freely out there.
Here is my web page; http://www.greenescortsinkolkata.co.in
I like this web site because so much utile material on here
:D.
Feel free to visit my web-site; allenspark.askmeclassifieds.com
Hi my loved one! I wish to say that this post is awesome,
great written and include approximately all important
infos. I would like to look extra posts like this .
hello there and thank you for your information – I have certainly
picked up anything new from right here. I did however expertise several technical
issues using this site, as I experienced to reload the web site a lot
of times previous to I could get it to load properly.
I had been wondering if your web hosting is OK? Not that I am complaining, but slow loading
instances times will often affect your placement in google and could damage your quality score if ads
and marketing with Adwords. Well I am adding this RSS to my e-mail and could
look out for a lot more of your respective exciting content.
Ensure that you update this again very soon.
In fact, there is generally no limit to how several bets you can group with
each other this way.