I need help to make Visual Basic not stop while sending emails.
I am using Smtp_Server.Send(e_mail) everytime it's sends an email the program stops for 5 seconds and then it's stop work for maybe 3 sec and then it sends the mail.
I want to be able to still use the program while it's sends the mail Help plz!
You can use some logging or careful observation in the debugger to confirm, but the conversation between your client and the SMTP server is probably taking 5 seconds (which is quite long, but plausible).
The solution is to use multiple threads to send email.
If you are sending batches of emails, try starting with 5-10 threads (with too many, the SMTP server on the other end might start rejecting some connection attempts).
If you are trying to send a single email at a time, but it is blocking your main application, you can use a single separate thread to perform the send.
Related
I've built a small telegram bot using python-telegram-bot.
When a conversation is started,I add a periodical job to the job queue and then message back to the user every X minutes.
Problem is when my bot goes offline (maintenance, failures, etc), the jobqueue is lost and clients do not receive updates anymore unless they send /start again
I could maybe store all chat_ids in a persistent queue and restore them at startup but how do I send a message without responding to an update ?
you have lots of options. at first you need to store all chat_ids. you can do it in database or simple text file.
then you need a trigger in order to start sending messages. I'm not familiar with your technology but i just create simple service in order to do it.
i have GSM modem (ZTE MF112) connected via USB port. I can send and receive SMS with this modem through serial port but i want to monitor the modem continuously for received SMS. if an SMS received, i want to connect the database, search the required information and send it back to the sender.
i need the whole process auto-method without any human interference.
like:
A function which will monitor the Serial port
if an SMS is received, it will call another function and pass the queried information to it and that function will connect the database. if information is found that information will be return otherwise some message will be return to the first function.
Note: The code is needed in VB.Net
some body help me plz.
One way is you make a loop which check for for any unread messages after certain time period like 5 sec or 10 sec if there is any unread message it gets it from modem parse it and display it
I have figured it out. I have added a timer to my application and set its delay to 5000 ms (5 s). Inside the timer_tick event I wrote the code to check and list up unread SMS from the modem.
I'm working with Sendgrid to send out emails Async (in vb.net) and want to notify the user when the process is complete. What's the fastest/easiest way to do this? I'm still new to threads and don't know how to wait on a sendgrid task/thread to finish.
Thanks
You should be able to use the Await keyword, to cause the cause execution to stop until the message has been sent to SendGrid:
Dim response = Await YourAsyncDeliveryFunction(email)
' Do what you want
However, sending a message to SendGrid does not mean that it's in the user's inbox. The email still needs to be processed by SendGrid, sent to the user's email service provider, which in turn needs to process it and provide that to the user. So, it's near impossible to tell a user when an email is actually in their inbox. Most people just opt to tell users that they should receive an email shortly.
We have one application(Rails 3) deployed in Heroku.
For sending email digest to nearly about 500 users, we are using delayed_job.
Notifier.delay.send_email_digest(digest_content, #user)
My application has 3 web dynos and 2 worker dynos.
Though the task is sending only one Email digest per user in local,
In heroku (production) it's sending two email digests for some users (strange).
Is it due to two worker dynos (but why?? or mere coincidence).
Can anybody help me solve the problem?
Thanks.
Within your send_email_digest method are you calling deliver? Delayed Job uses some magic when sending emails and it will automatically call deliver for you. If you call deliver yourself it will send multiple times. I've had this happen on occasion.
how to send SMS after 4 days from a Symbian app by running the application in the bachground. Means application sends SMS after 4 days? Is that possible?
Please reply soon.
I don't think you would want to achieve this by running your application in the background for 4 days. For a start, if the phone was rebooted or ran out of battery in that time then the SMS wouldn't get sent when it was switched on again.
Instead, you can use the message centre API to schedule the SMS to be sent at a particular time.
The TMsvEntry class lets you call:
SetScheduled(ETrue);
SetSendingState(KMsvSendStateScheduled);
and then you can set TMsvEntry::iDate which is a TTime to the date/time you want the message to be sent.
This example shows how to send an SMS, try looking at:
void CSmsEngine::SendSmsL(const TDesC& aAddr, const TDesC& aMsg)
Comment out the SendSMSInThirdEditionL call, since you need to use the older API.
Make your changes in:
TMsvId CSMSExampleMtmsEngine::CreateSMSMessageL(const TDesC& aAddress,
const TDesC& aMessage)
Alternatively, if what you want to achieve is to send an SMS every 4 days, then you can use the Symbian Task Scheduler to do this. You can create an EXE which sends the SMS, then create a task which will run the EXE every 4 days. It will not keep anything running in the background so it won't waste battery, and it will remember to run the task even if you reboot the phone in between runs, since it persists the schedule to disk.
This example
shows how to create a task - so in the DoRunTaskL function you can send an SMS, for instance.
This example
shows how to schedule the task itself.
So to start your SMS sending schedule you would need to do something like that but edit the schedule to be every 4 days.
I would say that this is a relatively advanced programming challenge on Symbian. So if you are new I'd recommend doing some of the tutorials, reading the books etc. before starting it.