using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Mail;
using Microsoft.Exchange.WebServices.Data;
namespace Email
{
class Program
{
static void Main(string[] args)
{
try
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
service.UseDefaultCredentials = false;
service.Credentials = new NetworkCredential("id_in_server", "Password_in_server");
service.Url = new Uri("https://myexchangeserver/EWS/exchange.asmx");
Console.WriteLine(service.Url);
service.TraceEnabled = true;
EmailMessage message = new EmailMessage(service);
message.Subject = "Hello from the EWS Managed API";
message.Body = "Good Job!";
message.ToRecipients.Add("recipient_mail_address");
//message.Save();
message.SendAndSaveCopy();
}catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}
I sent mail use EWS , C# without outlook and it worked ok.But in C++ , I can't, if use MAPI library 1 profile outlook required. I see a example use Webservice in C++ http://social.msdn.microsoft.com/Forums/en-US/wwsapi/thread/adf2a58c-32b7-477a-adcc-f2d053e2902b but I can't use this. Now, I want to send mail through exchange server use C++ without Outlook. Please help me. Thanks
I solved this problem.
Here is answer http://social.msdn.microsoft.com/Forums/en-US/wwsapi/thread/f0800af0-e62f-4b62-96e6-c504923ab77a
I used WWSAPI connect to exchange server with C++.
Related
I made a web application on visual studio 2017 for ASP.NET core. It has a contact option where users send me an email. It works perfectly in localhost as I receive the feedback. When I build/release using Azure DevOps onto azure app services in the portal my website at its URL loses the functionality of the email option. I wrote the email code using MailKit, if you guys have a better option that works let me know! Thank you.
var message = new MimeMessage();
message.From.Add(new MailboxAddress(inputEmail));
message.To.Add(new MailboxAddress("myemail"));
message.Subject = "Message from: " + inputName;
message.Body = new TextPart("plain")
{
Text = inputMessage
};
using (var client = new SmtpClient())
{
client.Connect("smtp.gmail.com", 587, false);
client.Authenticate("email", "password");
client.Send(message);
client.Disconnect(true);
};
return RedirectToAction("Index");
mywebsite.azurewebsites.net is currently unable to handle this request.
The problem is that you are using gmail. GMail only allows you to authenticate using SMTP/IMAP/POP3 after you've authenticated via the web from a particular device.
I am quite new to the ringcentral APIs and currently going through all of them.
Currently going through the following reference: https://developers.ringcentral.com/api-reference/SMS/createSMSMessage
Through Java we can use an API to send SMS, but can we receive a SMS using Java.
Can someone help me in getting the documentation/article or any kind of reference where I can get to know the simple way to send and receive the SMS using Java
A sample send SMS example with Java as follows:
import java.io.IOException;
import com.ringcentral.*;
import com.ringcentral.definitions.*;
public class Send_SMS {
String RECIPIENT_NUMBER = "<ENTER PHONE NUMBER>";
String RINGCENTRAL_CLIENTID = "<ENTER CLIENT ID>";
String RINGCENTRAL_CLIENTSECRET = "<ENTER CLIENT SECRET>";
String RINGCENTRAL_USERNAME = "<YOUR ACCOUNT PHONE NUMBER>";
String RINGCENTRAL_PASSWORD = "<YOUR ACCOUNT PASSWORD>";
String RINGCENTRAL_EXTENSION = "<YOUR EXTENSION, PROBABLY ";
public static void main(String[] args) {
var obj = new Send_SMS();
try {
obj.sendSms();
} catch (RestException | IOException e) {
e.printStackTrace();
}
}
public void sendSms() throws RestException, IOException{
RestClient rc = new RestClient(RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, RINGCENTRAL_SERVER);
rc.authorize(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD);
CreateSMSMessage postParameters = new CreateSMSMessage();
postParameters.from = new MessageStoreCallerInfoRequest().phoneNumber(RINGCENTRAL_USERNAME);
postParameters.to = new MessageStoreCallerInfoRequest[]{new MessageStoreCallerInfoRequest().phoneNumber(RECIPIENT_NUMBER)};
postParameters.text = "Hello World from Java";
var response = rc.restapi().account().extension().sms().post(postParameters);
System.out.println("SMS sent. Message status: " + response.messageStatus);
}
}
You can download the java SDK from here: https://github.com/ringcentral/ringcentral-java
and start with documentation here: https://developers.ringcentral.com/guide/messaging/quick-start/java
Once you get the library in your application, you can start compiling it and running it.
Here is a SMS Java quickstart guide: https://developers.ringcentral.com/guide/sms/quick-start/java
Hope this helps!
Here is the official RingCentral Java SDK: https://github.com/ringcentral/ringcentral-java, it is currently 1.0.0-beta9. We are going to release a stable version this month.
Here is a list of all the API calls that you can invoke: https://github.com/ringcentral/ringcentral-java/blob/master/samples.md, including sms sending: https://github.com/ringcentral/ringcentral-java/blob/master/samples.md#create-smsmms-message
For sms receiving, you can use our subscription and notification feature: https://github.com/ringcentral/ringcentral-java#pubnub-subscriptions--notificatioins
So whenever there is new sms, you will be notified, then you can issue api call to get the message.
For technical details, you can always send email to devsupport#ringcentral.com
Hi I am trying to automate AdvancedRestClient extension for Chrome to test webservice.
I am able to start the Extension and send request. But I am not able to get any response.
public class WebServices {
public static void main(String[] args) {
//Start the driver
System.setProperty("webdriver.chrome.driver","$PATH_TO_DRIVER");
ChromeOptions options = new ChromeOptions();
options.addArguments("load-extension=C:/Users/$username/AppData/Local/Google/Chrome/User Data/Default/Extensions/hgmloofddffdnphfgcellkdfbfbjeloo/3.1.7_0");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
ChromeDriver driver = new ChromeDriver(capabilities);
driver.manage().deleteAllCookies();
driver.manage().window().maximize();
//Start the extension
driver.get("chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/RestClient.html");
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//Get the authentication field and set authentication
WebElement authField = driver.findElement(By.xpath("//*[#id='appContainer']/div/div/div/div[4]/div[2]/section[1]/textarea"));
authField.sendKeys("$SET_AUTORIZATION")
//Get the reqestURL field and enter request
WebElement requestField = driver.findElement(By.xpath("//*[#id='appContainer']/div/div/div/div[2]/input"));
requestField.clear();
requestField.sendKeys("$REQUEST");
authField.click();
//Click on send button
WebElement sendButton = driver.findElement(By.xpath("//*[#id='appContainer']/div/div/div/div[7]/div/button[2]"));
sendButton.click();
}
}
The above steps work fine when I do it manually. But script does not generate any response.
Please help.
Automating a browser to test a web service is not the most reliable or efficient way.
You should instantiate a HttpClient in your test instead a Webdriver instance. This will allow you to make REST calls directly and interogate the response in the same way you would assert via WebDriver.
This approach will take milliseconds rather than seconds to run a test. Also, it can run anywhere without the need to install Chrome or Webdriver
I am trying to create a new term set in SharePoint 2013 using a custom WCF web service deployed within SharePoint 2013 server. I have written below code to create the term set.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (Impersonator imp = new Impersonator("Username", "Domain", "Password"))
{
using (SPSite site = new SPSite("http://server:8002/sites/site/"))
{
site.AllowUnsafeUpdates = true;
TaxonomySession session = new TaxonomySession(site);
TermStore termStore = session.TermStores["Managed Metadata Service"];
var termStoreAdmin = termStore.TermStoreAdministrators.Where(obj => obj.PrincipalName.Contains("domain\\username")).FirstOrDefault();
if (termStoreAdmin == null)
termStore.AddTermStoreAdministrator("domain\\username");
Group group = termStore.GetGroup(new Guid(groupGuid));
if (group != null && !string.IsNullOrEmpty(termSetName))
{
TermSet termset = group.TermSets.FirstOrDefault(obj => obj.Name.Equals(termSetName));
if (termset == null)
{
termset = group.CreateTermSet(termSetName);
termSetGuid = termset.Id.ToString();
}
SetupNavTermSet(termset, session, site.OpenWeb());
}
termStore.CommitAll();
}
}
});
I am calling this method from silverlight code using soap message. While calling this code I am getting exception while executing group.CreateTermSet(termSetName); line.
The error is:
Error Message : Value cannot be null.
Source : Microsoft.SharePoint
Error Details : at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetUserIdentifierEncodedClaim(IIdentity identity)
at Microsoft.SharePoint.Taxonomy.Internal.CommonUtilities.GetCurrentUserName()
at Microsoft.SharePoint.Taxonomy.TaxonomySession.get_CurrentUserName()
at Microsoft.SharePoint.Taxonomy.Group.CreateTermSet(String name, Guid newTermSetId, Int32 lcid)
at Microsoft.SharePoint.Taxonomy.Group.CreateTermSet(String name)
at SplitVisionMetadataManagement.CustomManageMetaDataWCFService.<>c__DisplayClassc.<CreateTaxonomyTermSet>b__8()
Has anybody got this issue and a solution?
I also encountered the same issue and figured out that the Microsoft.SharePoint.Taxonomy.Internal.CommonUtilities.GetCurrentUserName() method uses the HttpContext.Current.User security principal for arriving at the user name.
I am using similar code in a windows form application and hence the HttpContext was empty. I made a workaround by setting the context and user manually as below.
if (HttpContext.Current == null)
{
HttpRequest request = new HttpRequest("", SiteURL, "");
HttpContext.Current = new HttpContext(request, new HttpResponse(TextWriter.Null));
HttpContext.Current.User = System.Threading.Thread.CurrentPrincipal;
}
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(SiteURL))
{
using (SPWeb web = site.OpenWeb())
{
if (HttpContext.Current.Items["HttpHandlerSPWeb"] == null)
HttpContext.Current.Items["HttpHandlerSPWeb"] = web;
// Your SharePoint Term Creation code
}
}
});
In your case it seems like you are using claims based authentication and hence some issue with the claims provider in returning the name. You HTTP context would be the context under which the WCF is running. You may need to investigate further in those angle.
The above knowledge should help you to understand it further.
I am wondering how the process of sending email is working between Dynamics Ax client and Email client that is set for the server as default email client.
First of all can Dynamics Ax use alternative email clients (not outlook) for sending emails and second of all is Dynamics Ax sending whole configuration to the client, or client has to be configured by itself.
Right now I am experiencing unknown error while trying to send email using Windows Live Mail.
Dynamics AX uses MAPI for client mail.
You can use the SysINetMail::sendEMail method to send a simple mail using this.
If you mail in batch another option is to use SMTP mail using SysEmailTable::sendMail.
This requires the use of mail templates.
I know this is an old question but if someone else needs it...
I am using this on a Dynamics AX 2009 and it works like a charm :)
server static boolean sendEmail(EmplId _fromEmplId, EmplId _toEmplId, str _subject, str message, EmailPriority _priority = EmailPriority::Normal)
{
boolean ok = true;
SysEmailBatch emailBatch;
EmplTable fromEmplTable;
EmplTable toEmplTable;
Email fromEmail;
Email toEmail;
;
changecompany( -- TO YOUR MASTER COMPANY --)
{
fromEmplTable = EmplTable::find(_fromEmplId);
toEmplTable = EmplTable::find(_toEmplId);
fromEmail = fromEmplTable.email();
toEmail = toEmplTable.email();
if (! fromEmail)
{
ok = checkFailed(strfmt("no email set up for %1", _fromEmplId));
}
if (! toEmail)
{
ok = checkFailed(strfmt("no email set up for %1", _toEmplId));
}
if (ok)
{
emailBatch = SysEmailBatch::construct();
emailBatch.parmSendername(fromEmplTable.name());
emailBatch.parmSenderAddr(fromEmplTable.email());
emailBatch.parmEmailAddr(toEmplTable.email());
emailBatch.parmPriority(_priority);
emailBatch.parmSubject(_subject);
emailBatch.parmMessageBody(_message);
emailBatch.run();
}
}
return ok;
}
Using SysOutgoingEmailTable and SysOutgoingEmailData you can send email to recipient of any domain and attach files too.
you have following fields:
outgoingEmailTable.EmailItemId
outgoingEmailTable.IsSystemEmail
outgoingEmailTable.Sender
outgoingEmailTable.SenderName
outgoingEmailTable.Recipient
outgoingEmailTable.Subject
outgoingEmailTable.Priority
outgoingEmailTable.WithRetries
outgoingEmailTable.RetryNum
outgoingEmailTable.UserId
outgoingEmailTable.Status
outgoingEmailTable.Message
outgoingEmailTable.TemplateId
outgoingEmailTable.LatestStatusChangeDateTime
outgoingEmailData.EmailItemId
outgoingEmailData.FileName
outgoingEmailData.EmailDataType
outgoingEmailData.FileExtension
insert respective email detail in these tables and you are good to go. Further if it gives permission error do add permission set with
CodeAccessPermission::assertMultiple .