VBScript Launch Default Mail Window - asp-classic

Just wondering if it is at all possible in classic ASP/VBScript to launch a new window of the default mail client.
I have tried the following:
set objOutlk = createobject("Outlook.Application")
set objMail = objOutlk.createitem(olMailItem)
But got nothing but an error: ActiveX cannot create object: Outlook.Application.
Any advice is much appreciated.
Rob.

If you want to provide a simple way to open the default mail client message of a user viewing your (asp) page just add a mailto: hyperlink:
Send Msg
The mailto: will trigger the browser to open the default (or configured) mail client.
You can append a query string defining the subject line and the mail body - in my example the subject is "Hello World" and the body text is "Hi there".
Notice the blanks are url-encoded to %20

After a little thought (thanks to some of you guys for the prompt) it made sense to run this client side and I used the following JScript:
<script type="text/javascript">
function send() {
alert("clicked")
var recpt = "info#example.ccTLD"
var subj = "FASTER BETTER SOONER: Look at Monash Rowville rail now"
var text = "<Enter your name and address here> %0D%0DMelbourne is growing and more people need transport. With concern about climate change and rising petrol prices, Melbourne's growth is not sustainable without more and better public transport.%0D%0DVictorians want more people catching public transport, cycling and walking; fewer trucks on our roads, more freight on rail; and fewer kilometres travelled by car and truck.%0D%0DPublic transport should: be fast, frequent, reliable, affordable and safe; grow as Melbourne grows; be available to all Melbournians; and be managed as an integrated, co-ordinated network.%0D%0DThis means bringing forward existing public transport projects, committing to new projects and accelerating programs to move freight off our roads and onto rail.%0D%0DIt also means looking very closely at the impact on greenhouse gas emissions of any new transport projects like tunnels and freeways.%0D%0DWe especially urge you to look at a feasibility study for a Monash Rowville rail line. %0D%0DAs Melbourne's population grows, better public transport will both reduce traffic congestion and provide a much needed antidote to spiralling petrol prices. "
var bcc = "people#example.ccTLD"
var content = new Array()
content[0] = "mailto:"
content[1] = recpt
content[2] = "?subject="
content[3] = subj
content[4] = "&body="
content[5] = text
content[6] = "&bcc="
content[7] = bcc
content = content.join("")
window.location = content
}
This seems to the results I expected.
Rob

Related

R: Send text messages without the use of 3rd parties (or do it WITH your own number)

I'm trying to use R to send text messages - without using platforms like Twilio or Plivo. Is there an easy way to do this in R?
The platforms mentioned above make it easy to send text messages, but you have to get verification of the phone numbers / pay for a new number / jump through several hoops. I don't mind paying a small amount, either, but I do want to use my own number. Here's the set up for Twilio:
Sys.setenv(TWILIO_SID = "xxxxxxx...")
Sys.setenv(TWILIO_TOKEN = "xxxxxxx...")
my_phone <- "xxxxxxxxxx" # personal phone number / or number you want to send messages to
twilios_phone <- "xxxxxxxxxx" # the number they give you
tw_send_message(from = twilios_phone, to = my_phone,
body = "We the People of the United States, in Order to form a more perfect Union")
I can send messages to my own phone number, but I cannot send anything from my own number, which is the point of me asking this question.
The Plivo setup:
AUTH_ID = "xxxxx..."
AUTH_TOKEN = "xxxxxx......."
message <- "We the People of the United States, in Order to form a more perfect Union"
url = "https://api.plivo.com/v1/Account/xxxxxxx..../Message/"
POST(url, authenticate(AUTH_ID, AUTH_TOKEN),
body = list(src = "xxxx..", dst = "xx....",
text = message))
Both super simple setups, but how can I send messages (free or not) from MY own number, and do it easily? (And yes, I'm doing this to learn/ spam my friends with the Constitution once a month - a worthy cause, I know).

Paypal Processing - Need to grab TransactionId, CorrelationId and TimeStamp

Current Project:
ASP.NET 4.5.2
MVC 5
PayPal API
I am using this example to build myself a PayPal transaction (and yes, my code is virtually identical), as I do not know of any other method that will return the three values in the title.
My main problem is that, the example I am utilizing is much more concise and compact than the one I used for a much older Web Forms application, and as such, I am unsure as to where or even how to grab the three values I need.
My initial thought was to do so right after the ACK, and indeed I was able to obtain the CorrelationId as well as the TimeStamp, but because this was prior to the user being carted off to PayPal’s site (sandbox in this case -- see the return new PayPalRedirect contained within the if), the TransactionId was blank. And in this example, PayPal explicitly redirects the user to a Success page without returning to the Action that sent the user to PayPal in the first place, and I am not seeing any GET values in the URL at all aside from the Token and the PayerId, much less ones that could provide me with the TransactionId.
Suggestions?
I have also looked at the following examples:
For ASP.NET Core, was unsure how to adapt to my current project particularly due to appsettings.json, but it looked quite well done. I really liked how the values were rolled up in lists.
For MVC 4, but I couldn’t find where ACK was being used to determine success or successwithwarning so I couldn’t hook into that.
I have also found the PayPal content to be like trying to drink from a fire hose at full blast -- not only was the content was hopelessly outdated (Web Forms code, FTW!) but there was also so many different examples it would have taken me days to determine which one was most appropriate to use.
Any assistance would be greatly appreciated.
Edit: my initial attempt at modifying the linked code has this portion:
values = Submit(values);
var ack = values["ACK"].ToLower();
if(ack == "success" || ack == "successwithwarning") {
using(_db = new ApplicationDbContext()) {
var updateOrder = await _db.Orders.FirstOrDefaultAsync(x => x.OrderId == order.OrderId);
if(updateOrder != null) {
updateOrder.OrderProcessed = false;
updateOrder.PayPalCorrelationId = values["CORRELATIONID"];
updateOrder.PayPalTransactionId = values["TRANSACTIONID"];
updateOrder.PayPalTimeStamp = values["TIMESTAMP"];
updateOrder.IPAddress = HttpContext.Current.Request.UserHostAddress;
_db.Entry(updateOrder).State = EntityState.Modified;
await _db.SaveChangesAsync();
}
}
return new PayPalRedirect {
Token = values["TOKEN"],
Url = $"https://{PayPalSettings.CgiDomain}/cgi-bin/webscr?cmd=_express-checkout&token={values["TOKEN"]}"
};
}
Everything within and including the using() is my added content. As I mentioned, the CorrelationId and the TimeStamp come through just fine, but I have yet to successfully obtain the TransactionId.
Edit 2:
More problems -- the transactions that are “successful” through the sandbox site (the ReturnUrl is getting called) aren’t reflecting properly on my Facilitator and Buyer accounts, even when I do payments straight from the buyer’s PayPal account (not using the Credit Card). I know I am supposed to see transactions in the Buyer’s account, either through the overall Dev account (Accounts -> Profile -> balance or Accounts -> Notifications) or through the Buyer’s account in the sandbox front end. And yet -- multiple transactions returning me to the ReturnUrl path, and yet no transactions in either.
Edit 3:
Okay, this is really, really weird. I have gone over all settings with a fine-toothed comb, and intentionally introduced errors to see where things should crap out. It turns out that the entire process goes swimmingly - except nothing shows up in my notifications and no amounts get moved between my different accounts (Facilitator and Buyer). It’s like all my transactions are going into /dev/null, yet the process is successful.
Edit 4: A hint!
In the sandbox, where Buyer accepts the transaction, there is a small note, “You will be able to review the transaction before completing it” or something like that -- suggesting that an additional page is not coming up and that the user is being uncerimoniously dumped back to the success page. Why the success page? No clue. But it’s happening.
It sounds like you are only doing the first part of the process.
Express Checkout consists of 3 API calls:
SetExpressCheckout
GetExpressCheckoutDetails
DoExpressCheckoutPayment
SEC generates a token, and then you redirect to PayPal where the user signs in and reviews the transactions before agreeing to pay.
They are then sent to the ReturnURL included in your SEC request, and this is where you'll call GECD in order to obtain all the buyer details that are now available since they signed in.
Using that data you can complete the final DECP request, which is what finalizes the procedure. No money is actually processed until this final call is completed successfully.

Memory leak while sending response from rebus handler

I saw a very strange behavior in my rebus handler which is self hosted in exe. Right after sending response using bus.send method it adds up some memory consumed by process. I tried to look up object graph using memory profile and found that rebus is holding response message in serialized format somewhere.
Object graph was showing below hierarchy to the root.
System.Message --> CachedBodyMessage --> stream
Give me some pointers if anybody is aware of this thing.
I understand that a memory leak is a grave concern, but my belief is that it is unlikely that Rebus should contain a memory leak.
This belief is rooted in the fact that I have been running Windows Service-hosted Rebus endpoints in production for 1,5 years now, and several of them (e.g. the timeout managers) have sometimes been running for several months without being restarted.
I'd like to be absolutely bulletproof sure though, so I'm willing to investigate the issue you're reporting.
You're mentioning "CachedBodyMessage" - judging by the names of fields inside System.Messaging.Message, it sounds like it's something within MSMQ. To try to reproduce your issue, I coded the following test:
[Test, Ignore("Only works in RELEASE mode because otherwise object references are held on to for the duration of the method")]
public void DoesNotLeakMessages()
{
// arrange
const string inputQueueName = "test.leak.input";
var queue = new MsmqMessageQueue(inputQueueName);
disposables.Add(queue);
var body = Encoding.UTF8.GetBytes(new string('*', 32768));
var message = new TransportMessageToSend
{
Headers = new Dictionary<string, object> { { Headers.MessageId, "msg-1" } },
Body = body
};
var weakMessageRef = new WeakReference(message);
var weakBodyRef = new WeakReference(body);
// act
queue.Send(inputQueueName, message, new NoTransaction());
message = null;
body = null;
GC.Collect();
GC.WaitForPendingFinalizers();
// assert
Assert.That(weakMessageRef.IsAlive, Is.False, "Expected the message to have been collected");
Assert.That(weakBodyRef.IsAlive, Is.False, "Expected the body bytes to have been collected");
}
which verifies that the sent transport message is collected as it should (will only do this in RELEASE mode though, because of the way DEBUG mode holds on to object references within scope)
I'll try and run the TimePrinter sample now and leave it running for a while to see if I can reproduce the issue. If you stumble upon more information about e.g. exactly which objects are leaking, it would be very helpful.
Thanks again for taking the time to report your worries to me :)
Followup:
I've modified the TimePrinter sample so that it sends 50 msg/s and includes a 64 KB random string payload with each message, and I've tracked the memory usage for almost four hours now. As you can see, it does not look like memory is being leaked.
I'll leave it running the rest of the day, just to be sure.
Maybe you can tell me some more about why you suspected there was a memory leak in the first place?
Update:
As you can see from the trace, it has now been running for 7 hours and thus more than 1,200,000 messages containing more than 70 GB of data has been sent and consumed by the same process. If cached message bodies were leaking, I am pretty sure that we would have been able to see something rising on the graph.

Google Maps API: Bring up address selections as you type

I'm looking to create a web application that starts to suggest home addresses as you type. For instance, imagine a pizza delivery company, where you start typing in your address, "1279", and beneath the box it brings up 1279's in the US for people to choose from, like:
1279 Main Street, St. Louis, MO
1279 Tree Street, Baltimore, MD
In this way, it would really mirror maps.google.com in bringing up suggestions as you type.
I've looked through the Google Places and Maps APIs without much success. The GeoCoding one works OK by passing an address parameter through, but often returns no results or really bad ones... nothing like maps.google.com. Plus they're difficult to parse. (The address parts parameters aren't always consistent, meaning that I have to send the formatted address through another parser... not a deal-breaker though.)
Anyone else have any suggestions out there? Thanks! Jeremy
You can improve the Places autocomplete results by passing bounds option when creating it. The example binds it to the map viewport:
autocomplete.bindTo('bounds', map);
In this demo I hardcoded the continental US bounds (plus some of Mexico and Canada)
var input = document.getElementById('searchTextField');
var autocomplete = new google.maps.places.Autocomplete(input,
{bounds: new google.maps.LatLngBounds(
new google.maps.LatLng(23.730197707069532, -126.14240169525146),
new google.maps.LatLng(50.1805258484942, -65.32208919525146)) }
);

Recommend a good Interactive Voice Response system to work with .NET?

I have a client in the healthcare space, that might need an IVR system to take patients through a simple six question survey (all of the "press 1 for I Strongly Agree, up to 5 for I Strongly Disagree" type). The factors involved...
Small client: We don't need enterprise-level firepower. We'd expect maybe 50-100 surveys per month.
Hosted: We will be setting up an ASP.NET server with a SQL Server database hosted at a co-location facility. We don't have our own server room and pipes to the internet. I'll want something already hosted that I can tie into. (It needn't be on my ASP.NET server, of course.)
Integration: The rest of their system will be .NET and SQL Server based, so I want to be able to automate pulling the data from the IVR system into my own
Ad-Hoc: We won't be robo-calling. A typical scenario for us: My client receives a live call from a patients...and at the end, will say "Do you have another minute? Can I have you take a phone survey?" If the patient says yes, then either...
they hang up, my client dials a few commands into the IVR system, at the IVR calls the patient...or...
my client doesn't hang up, but transfers the current phone call to the IVR system
Suggestions?
Check out twilio
I believe surveymonkey has an implementation over this API that might also work for you.
I've used Microsoft Speech Server 2007 (Part of Office Communications Server 2007) in the past and it will meet all of your requirements. You can find out more about it here: http://gotspeech.net/
It looks like Speech Server 2007 has been renamed Tellme and you can find out more here: http://www.microsoft.com/en-us/Tellme/developers/default.aspx
I have not used the new Tellme version, but Speech Server 2007 was great. You could implement an entire IVR system within Visual Studio using workflows and .NET code. I would expect Tellme probably makes it even easier.
Ricky from Twilio here.
We put together a C# tutorial for this exact use case I wanted to share:
https://www.twilio.com/docs/tutorials/walkthrough/automated-survey/csharp/mvc
There's a sample configuration that lets you set all the survey questions you want to ask:
protected override void Seed(AutomatedSurveysContext context)
{
context.Surveys.AddOrUpdate(
survey => new { survey.Id, survey.Title },
new Survey { Id = 1, Title = "Twilio" });
context.SaveChanges();
context.Questions.AddOrUpdate(
question => new { question.Body, question.Type, question.SurveyId },
new Question
{
Body = "Hello. Thanks for taking the Twilio Developer Education survey. On a scale of 0 to 9 how would you rate this tutorial?",
Type = QuestionType.Numeric,
SurveyId = 1
},
new Question
{
Body = "On a scale of 0 to 9 how would you rate the design of this tutorial?",
Type = QuestionType.Numeric,
SurveyId = 1
},
new Question
{
Body = "In your own words please describe your feelings about Twilio right now? Press the pound sign when you are finished.",
Type = QuestionType.Voice,
SurveyId = 1
},
new Question
{
Body = "Do you like my voice? Please be honest, I dislike liars.",
Type = QuestionType.YesNo,
SurveyId = 1
});
context.SaveChanges();
}

Resources