Sending mail from Third party sites Programmatically [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
How can I send mail from sites other than gmail, hotmail, rediffmail. Without any API provided. Is there provision to make this happen in any of programming languages. I think the domain I'm going to use does not have any captcha checks.
I also would like to attach a folder within.

If you are asking about other domain names, like your own domain then you can use below method:
Add using System.Net.Mail;
then below in some event
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("mail.yoursite.com");
mail.From = new MailAddress("testing#yoursite.com");
mail.To.Add("youremail#address.com");
mail.Subject = "New Email";
mail.Body = "add text here from controls";
SmtpServer.Port = 25;
SmtpServer.Credentials = new System.Net.NetworkCredential("testing#yoursite.com", "passhere");
SmtpServer.EnableSsl = false;
SmtpServer.Send(mail);
MessageBox.Show("All Done");

Related

how can I get the member mentioned and displayed in the embed [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last month.
Improve this question
if(msg.equalsIgnoreCase("hi")){
Member member = event.getMessage().getMentions().getMembers().get(0);
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setColor(Color.cyan);
embedBuilder.setDescription("Hello, " + member.getUser().getName() + "!");
embedBuilder.build();
event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
message: hi #mentioned
expected answer: hello #mention or name
Get the user's ID and put it in between of <# and >. Example: <#355314189117554689>.
if (msg.equalsIgnoreCase("hi")) {
Member member = event.getMessage()
.getMentions()
.getMembers()
.get(0);
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setColor(Color.cyan);
// simply put the users snowflake ID between <# and >
embedBuilder.setDescription("Hello, <#" + member.getUser().getId() + ">!");
embedBuilder.build();
event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
}
To get a mention of a member you can use member.getAsMention(), in your case if you would like to actually mention someone, you would need to do it in the actual message (not the embed itself) as embeds do not support mentions and so it will be formatted in a weird way.
Alternatively you can just get the users name using member.getEffectiveName() and prepend it with '#' so it would look like a mention, but won't actually mention anyone

Assert the URL or Navigate to it appropriately [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have one question - how to write a cucumber hook that asserts the web URL.
Example -
Let's say I am testing - https://www.usatoday.com/tech/
My Given is as follows -
Given I am on the "/tech/" page
I would like a method to add the base url (www.usatoday.com) + "/tech" and assert whether it is currently on that page
(driver.getURL() ==www.usatoday/tech/)
otherwise navigate to that page if I am not there.
Any Java pros that can help me with this? Many thanks my friends.
#Given("^I am on the \"([^\"]*)\" page$")
public void i_am_on_the_page(String arg) throws throwable{
String newBaseURL = getBaseURL() + arg;
String currentURL = driver.getCurrentURL();
try{
Assert.assertEquals(newBaseURL, currentURL);
}
catch(Exception e){
driver.get(newBaseURL);
}
}
I am assuming that you have a function - getBaseURL() that will provide you the base url.

Country Holiday list [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
The requirement is to choose a country from a dropdown and display the list of holidays for the country chosen. Please let me know if there are any APIs that accomplish this.
You don't need to use any third party API for it, you can do it with google Calendar API like this
com.google.api.services.calendar.Calendar client = null;
credential = GoogleAccountCredential.usingOAuth2(mContext, CalendarScopes.CALENDAR);
credential.setSelectedAccountName(mList.get(0));
client = getCalendarService(credential);
do {
com.google.api.services.calendar.model.Events events;
events = client.events().list("en.usa#holiday#group.v.calendar.google.com").setPageToken(pageToken).execute();
onHolidayChecked(events.getItems()); //result return here (events.getItems())
pageToken = events.getNextPageToken();
} while (pageToken != null);
private com.google.api.services.calendar.Calendar getCalendarService(GoogleAccountCredential credential) {
return new com.google.api.services.calendar.Calendar.Builder(AndroidHttp.newCompatibleTrans port(), new GsonFactory(), credential).build();
}
Only solution I found is that to either add it statically in your string.xml
or
Try this API which google provides
1) Register a project at https://code.google.com/apis/console
2) Generate a Simple API Access key
3) Ensure Calendar API is activated under services.
Read more at https://developers.google.com/google-apps/calendar/firstapp
checkout this sample

FaceBook ShareLinkContent setImageUrl image is overriden by setContentUrl meta-data image [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am trying to Post the below infromation to FaceBook from Myapp using FaceBook ShareLinkContent class
- link url (using SetContentUrl method)
- image (using setImageurl method)
- hashtags (using setHashTag method)
- and Description
as like
ShareHashtag shareHashTag = new ShareHashtag.Builder().setHashtag(hashtag_name).build();
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setImageUrl(Uri.parse(selectedImagePath))
.setShareHashtag(shareHashTag)
.setContentDescription(textd)
.setContentUrl(Uri.parse(linkUrlPath))
.build();
shareDialog.show(linkContent);
}
} else {
shareImage();
}
The question is, instead of posting the image from "selectedImagePath" url, it post the meta-data image coming from the "linkUrlPath" url.
How to overcome it, so that i can post the image which i send in the method setImageUrl() method.
note: I am using Facebook SDK 4.14.1
Kindly provide suggestions
I guess this is what you are looking for -
Template Matching
Template Matching is a method for searching and finding the location of a template image in a larger image. OpenCV comes with a function matchTemplate() for this purpose. It simply slides the template image over the input image (as in 2D convolution) and compares the template and patch of input image under the template image.

Ensuring if excel worksheet contains any user defined function [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
My application contains an upload option from which the user can upload files(any file).
I know that users have the ability to write code/scripts in excel worksheet.So how can i prevent that from happening as it can lead to security breach.
Or what check can i apply to know that the uploaded worksheet contains any function?
I assume from the Java tag that your appliction to which the sheet gets uploaded is a Java application.
Using Apache POI, you can use a POIFSReader (see this doc) to read the file on a lower level.
There is an example by Réal Gagnon which shows how you can check the content by looking at the name.
I had to modify the listener (added another comparision)
class MacroListener implements POIFSReaderListener {
[...]
#Override
public void processPOIFSReaderEvent(POIFSReaderEvent event) {
System.out.println(" Event: Name " + event.getName() + ", path "
+ event.getPath());
if (event.getPath().toString().startsWith("\\Macros")
|| event.getPath().toString().startsWith("\\_VBA")
|| event.getPath().toString().contains("_VBA_")) {
this.macroDetected = true;
}
}
}
so that it worked for some test files. You might have to tune/extend the checks.

Categories