SendGrid - Efficient Real Estate Email Composition [closed] - sendgrid

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm trying to do the following using the latest SendGrid php information found here.
For a real estate portal, let's say a few people (5) are interested in an open house in Florida, represented by a real estate agent. An array includes their emails like this $prospect_email_array[], names like this $prospect_name[], realtor like this $realtor, and location like this $location. What would be the appropriate way to send an email out to them, in one go, as blind copies (so no prospect sees other prospects email addresses), efficiently. I am looking for comprehensive code to accomplish this. So far, on the php side, I have this pseudo code:
To: $prospect_email_array[]
From: mail#realestatesite.com
Title: $realtor's Open House in $location Welcome
Body:
Dear $prospect_name[],
I hope to see you in our upcoming open house in $location.
Looking forward to seeing you there!
Best Wishes,
$realtor
In addition, having a plain text version and html version is what I'm after. Will the equivilant of 2 'br' tags be preserved in plain text? Are 2 'br' tags needed in the html version for spacing as above? There may be emails for open houses, house interest, and potential buyers. Would these be the categories to use in SendGrid? Also, is utf-8 supprorted by default, or do we need to pass something to SendGrid?

Here's some "pseudo code" that should accomplish most of what you're trying to do. I haven't tested this at all and it's quite possible that there are typos and irregularities in it. It should get you moving in the right direction though.
<?php
include 'path/to/sendgrid-php/SendGrid_loader.php';
$sendgrid = new SendGrid('username', 'password');
$mail = new SendGrid\Mail();
$mail->setFrom('mail#realestatesite.com')->
setSubject($realtor . "'s Open House in " . $location)->
setText('[Fill this in yourself as an exercise]')->
setHtml('Dear %name%,<br />I hope to see you in our upcoming open house in ' . $location . '. <br /> Looking forward to seeing you there! <br /> Best Wishes, <br />' . $realtor);
$mail->setRecipientsInHeader(true);
foreach ($prospect_email_array as $prospect) {
$mail->addTo($prospect);
}
$mail->addSubstitution("%name%", $prospect_name);
$sendgrid->smtp->send($mail);

Related

How to use VBScript to lock a specific region of a Word document?

So I want to make a specific part of a Word document read-only using VBScript.
The version of Word I am using is from Office 16.
How to do this manually (recorded a macro for this to see if I would get a better idea on how to do this) I found here.
I know how to lock the entire document, and know that the following works:
'Protect Document
objDoc.Protect wdAllowOnlyReading, True, "password"
I saw this question being asked (on an old MS forum), but nothing more than this.
Any help with this sort of issue on an example I would appreciate.
While you can't do this using the Protect() method directly the answer appears to be in the Question you linked from the MS Forum.
' Protect Document
objDoc.Protect wdAllowOnlyReading, True, "password"
' Select last paragraph of the document
objDoc.Paragraphs.Last.Range.Select
' Make an exception for current selection
objWord.Selection.Editors.Add(-1) ' -1 = everyone
Using the Selection object you can modify the Editors on a protected document selection to "everyone" which unprotects that selection only leaving the rest of the document still protected.

Add an Intro page to exam in R/exams

I am using R/exams to generate Moodle exams (Thanks Achim and team). I would like to make an introductory page to set the scenario for the exam. Is there a way to do it? (Now, I am generating a schoice with answerlist blank.)
Thanks!
João Marôco
Usually, I wouldn't do this "inside" the exam but "outside". In Moodle you can include a "Description" in the "General Settings" when editing the quiz. This is where I would put all the general information so that students read this before starting with the actual questions.
If you want to include R-generated content (R output, graphics, data, ...) in this description I would usually include this in "Question 1" rather than as a "Question 0" without any actual questions.
The "description" question type could be used for the latter, though. However, it is currently not supported in exams2moodle() (I'll put it on the wishlist). You could manually work around this in the following steps:
Create a string question with the desired content and set the associated expoints to 0.
Generate the Moodle XML output as usual with exams2moodle().
Open the XML file in a text editor or simply within RStudio and replace <question type="shortanswer"> with <question type="description"> for the relevant questions.
In the XML file omit the <answer>...</answer> for the relevant questions.
Caveat: As you are aware it is technically possible to share the same data across subsequent exercises within the same exam. If .Rnw exercises are used, all variables from the exercises are created in the global environment (.GlobalEnv) and can be easily accessed anyway. If .Rmd exercises are used, it is necessary to set the envir argument to a dedicated shared environment (e.g., .GlobalEnv or a new.env()) in exams2moodle(..., envir = ...). However, if this is done then no random exercises must be drawn in Moodle because this would break up the connections between the exercises (i.e., the first replication in Question 1 is not necessarily followed by by the first replication in Question 2). Instead you have to put together tests with a fixed selection of exercises (i.e., always the first replication for all questions or the second replication for all questions, ...).

TYPO3 : no updated newsletter with direct_mail and scheduler

This is my 1st question on this forum... So, please, be indulgent !
I'm using TYPO3 4.7.11 (PHP 5.3.3) with extension direct_mail 3.1.1 for the intranet site of a non-profit firm.
My problem (maybe connected to Bug #51583 : http://forge.typo3.org/issues/51583) is that, after numerous tests and attempts, it seems impossible to have an updated version of a page saved as draft for newsletter in an automatic scheduler driven way : the same newsletter is produced with the same informations that were already there on the day it was first created and saved.
The specific page used for newsletter includes a content element 'Menu/Sitemap' with 'Recently updated pages' as 'Menu type'. It has been saved as 'draft (for recurring sendings)' in Direct Mail.
The scheduler contains these 2 tasks with recurring type :
- Direct Mail: Create Mail from Draft (direct_mail)
- Direct Mail: Mailing Queue (direct_mail)
Note : the manual way is fully functional and the newsletter produced is really updated. Same with option "Testmail - Simple" !
So, my problem seems to be linked to the automatic scheduled mailing ! It looks as if the newsletter draft has turned into a freezed snapshot of a specific moment and that Typo3 is unable to update/recalculate this page when invoked in scheduler mode.
On the web, I saw reported problems that could be related like "When mails get sent via the scheduler the same subject is used for all sendings ( https://review.typo3.org/21313 )" and "Adding hooks when sending direct mails via scheduler ( forge.typo3.org/issues/48994 )", but these issues seem to be fixed with direct_mail 3.1.1 version.
I made these observations and, in my opinion, there is some relevancy :
1.There is no domain proposed in the 'Domain of internal links' drop-down list in 'Set default values for mail content fetching options' in Direct Mailer, and yet I have a single record in sys_domain table with a domain name (with no protocol and no final slash). Is there a reason why this record is not considered good, or isn't it the right table ? (uid=3, pid, tstamp, crdate, cruser_id, hidden, sorting, prepend_params and forced=0, redirectHttpStatusCode=301, domain_name=site.subdomain.domain, redirectTo=)
2.In the Typo 3 Log, I get this systematic error message for user _cli_scheduler#LIVE :
Core: Error handler (BE): PHP Warning: Invalid argument supplied for
foreach() in
...typo3conf/ext/direct_mail/Classes/Scheduler/MailFromDraft.php line
125.
The concerned part of MailFromDraft.php is this function : initializeHookObjects
...
/*
* Initializes hook objects for this class
*
* #return void
*/
function initializeHookObjects() {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['direct_mail']['mailFromDraft'] as $hookObj) {
$hookObjectInstance = t3lib_div::getUserObj($hookObj);
if (is_object($hookObjectInstance) && ($hookObjectInstance instanceof x_directmail_Scheduler_MailFromDraftHook)) {
$this->hookObjects[] = $hookObjectInstance;
}
}
}
...
I'm not sure of understanding very clearly the origin and the use of the hook Object... (in spite of this interesting article by Robert Lemke : typo3.org/documentation/article/how-to-use-existing-hooks-in-your-own-extension/ )
3.Nothing like the apparently requested GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['direct_mail']['mailFromDraft'] seems to exist in TYPO3_CONF_VARS (Global configuration).
Can anybody give me an advice or a clue about what's going on and why I can't get a weekly updated newsletter with the scheduler ? I feel a bit confused !
Thanks in advance for any suggestion or solution (if a miracle is possible).
Greetings.
P-H SILLIAU
I've read about this issue before, but couldn't remember where.
Googling "direct_mail draft (for recurring sendings)" helped.
Try this bug: http://forge.typo3.org/issues/4421
User Markus says:
Things work fine, when you set a domain-record in your system and
select it in the direct_mail settings!
If you don't have a domain-record and specify it in the direct_mail
setup you're able to send normal newsletters, but if you try the
draft-functionality it won't work because the getUrlBase function in
class.tx_directmail_static.php returns an unsuable URL to the System
so it can't use the fetchHTML($file) and quits - therefore not
replacing the old draft contents created when starting the first time.
I don't really get why this works the first time you set up the draft
though....
So setting up the domain-record is a work-around that works.
I hope it does!
Probably, you will find more related topics.
Else, workarounds would be
re-considering the task. As it's a NPO intranet, maybe requirements are not that required suddenly, if asked again :-)
setting up a custom notification tool that only does that precise job.
To put an end to this problem, after many attempts (and informations gleaned from the internet), here is the solution we finally used in our specific case to make the newsletter work :
1st. We created a record in table sys_domain. This was a recurrent instruction in the manual and the forums, and it was IMHO legitimate.
Important : note that the redirectTo field had to remain empty, due to global malfunction of the site if filled (whatever we put in it like /, /var/www/sitename, ...)
2nd. All images, CSS, JS included in template had to be hardcoded (i.e. http ://site/fileamin/images/xxx.png for instance). If we didn't do that, the result would have been an abort in the production of the newletter : Not Found... Maybe, by digging a bit deeper, should we be able to find a parameter we forgot or neglected in some way to solve this issue...
3rd. In the newsletter template TS setup, we added these 2 parameters :
mod.web_modules.dmail.use_domain=[uid of sys-domain]
config.absRefPrefix = / (in order to get rid of PHP DOCUMENT_ROOT (or TYPO3_DOCUMENT_ROOT ?) otherwise wrongly present in all generated links.)
The result is now a well dynamically-generated newsletter, the date is OK, all links are correct and realUrl-compliant (no ../index.php?id=nnn) .... and you know what ?... We're happy ! :-)
Hope it will help !
Many thanks to everybody who answered (Markus, Urs...) or even thought of a possible solution...
P-H Silliau

Apex Trigger - Attempting to send an email after an update

so I have just finished a degree in computing and have just started industry related employment and wow... we really don't seem to learn much at uni, just the bare basics.
Anyway, I am learning Apex and attempting to write my first trigger. The online tutorials are pretty unforgiving and I find that they seem to all miss out what my brain is lacking.
I am writing a trigger to automatically send an email to a specified address, the sending the email part is fine however I want to send in the email what has been changed and read as to whether it anything has been changed. What I have so far is as follows:
trigger Test1 on Account (after update) {
if(Trigger.isUpdate) {
//Commit current transaction, reserver email capacity
Messaging.reserveSingleEmailCapacity(1);
//Create an email message object
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
List<Messaging.SendEmailResult> results = new list<Messaging.SendEmailResult>();
//hold email address
String[] toAddresses = new String[] {'example#example.com'};
//Assign new address string
mail.setToAddresses(toAddresses);
//specify return ad (assuming as being sent from server)
mail.setReplyTo('pwitherby#gmail.com');
//sender name
mail.setSenderDisplayName('Mr Apex Tester');
//Subject Specification
mail.setSubject('Subjected to Learning');
//And... the content
mail.setPlainTextBody('You have just changed sumek... this really what you want....?')
if (!results.get(0).isSuccess())
System.debug('That didnt really work did it? Reason: ' + results.get(0).getErrors()[0].getMessage());
}
}
So my main questions that I cant find an answer for:
Will this work at current? so will this send this email if anything in the schema gets altered/updated?
I want to put in the email body what has been altered and what it has been changed to i.e "you have changed " + whatsChanged + " to " + telephoneNumber.
How do I listen for changes or is it already doing that?
Am I writing this to a decent standard or is it just messy code!
Sorry to waffle, it is my biggest downfall however I struggle to augment my questions without it!
You don't need to activate a trigger just writing it is enough.
You can access the changed new values Through Trigger.new (and Trigger.old for old values)
For Trigger documentation refer here
Maybe a workflow is more suitable to what you are trying to do.
And finally don't worry too much from the start about standard of the code (or beauty), it makes difference only when your code gets big anyway.

how to import .xml file to database [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
hi i want to import my .xml file to sql server database in asp.net 3.5 c# for windows application.so give m rply as fast as posible.
this might help you http://support.microsoft.com/kb/316005
this code snippet might be helpful
DataSet reportData = new DataSet();
reportData.ReadXml(Server.MapPath(”report.xml”));
SqlConnection connection = new SqlConnection(”CONNECTION STRING”);
SqlBulkCopy sbc = new SqlBulkCopy(connection);
sbc.DestinationTableName = “report_table”;
//if your DB col names don’t match your XML element names 100%
//then relate the source XML elements (1st param) with the destination DB cols
sbc.ColumnMappings.Add(”campaign”, “campaign_id”);
sbc.ColumnMappings.Add(”cost”, “cost_USD”);
connection.Open();
refer http://www.akamarketing.com/blog/135-importing-xml-into-sql-server-table-aspnet.html
It's not brilliant, but you could read an XML file into a dataset and then use a data adapter to then populate the database...that would require very few lines of code, but not something you'd really want to hold onto...more of a once off dataload.
first u ve 2 manipulate d xml file using an xml parser, so that the elements in the xml document converts into objects that can be accessed by other applications
If this is something you are doing that is considered to be preprocessing, I would consider using SSIS: Import XML to SQL Server