Error in SPUtility send email - sharepoint

I am trying to send an email in the button click event in the webpart.However, the email sending is failed and error is logged in both sharepoint logs and event viewer of the machine.
The error is : Cannot connect to SMTP host
Outgoing email settings in central admin is already configured. Alerts are also working fine.
Below is my code:
StringDictionary headers = new StringDictionary();
headers.Add("to", "someone#abc.com");
headers.Add("from", "MySharePointEmail#myfatblog.co.uk");
headers.Add("subject", "How to use SendEMail from SPUtility");
headers.Add("content-type", "text/html");
string bodyText = "This is the body of my email, in html format.";
SPUtility.SendEmail(SPContext.Current.Web, headers, bodyText);
Thanks in advance

Try running your code without the System Account (if you are).
Try also disabling the LoopbackCheck:
To set the DisableLoopbackCheck registry key, follow these steps:
Click Start, click Run, type regedit, and then click OK.
In Registry Editor, locate and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
Right-click Lsa, point to New, and then click DWORD Value.
Type DisableLoopbackCheck, and then press ENTER.
Right-click DisableLoopbackCheck, and then click Modify.
In the Value data box, type 1, and then click OK.
Quit Registry Editor, and then restart your computer.

I got that fixed. Anti virus was causing the problem. But i am wondering how is SharePoint able to send mail then?

Related

Goggle - Cannot create credentials

Cannot create credentials, when I click the "Create credentials" button in the credentials page in console.cloud.google.com, the page will show a list, "API Key", "OUauth client ID", etc as you can see in my screenshot. I want to create an API Key, but the option cannot be clicked, when i set my cursor to the option, "Navigation menu" tooltip appears, and when clicked, it will show the page menu. How do I fix this? Anyone have similar issue? I'm using chrome, trying in firefox but to no avail.

Buildfire: Confirm notifcation behavior differs (and fails) in control panel and device but works in localhost

I am seeing an issue when attempting to use the confirm notifications functionality. It works fine in the dev environment but when uploaded and testing in the control panel or application it doesn't work. The callback returns a null data object and err=true where in the dev environment the data object has the selected button key available to action on. This is the only way to distinguish between the confirm button and cancel button being pressed (for the confirm notification).
The confirm notification documentation is here:
https://github.com/BuildFire/sdk/wiki/How-to-use-Notifications
The console output for the success (in dev/localhost):
Success
The console output for the same code in the control panel (and device):
Failure
This is a known bug that is being worked on. Here is an ugly workaround.
buildfire.notifications.confirm({message:"Are you sure you want to delete this epic?",confirmButton:{type:"danger"}},(e,r)=>{
if(e==1 || r.selectedButton.key == "confirm" ){ // confirmed }};

How to fix Google Calendar API error

I following https://developers.google.com/google-apps/calendar/quickstart/nodejs#step_3_set_up_the_sample
But it not worked and output below this:
var clientSecret = credentials.installed.client_secret;
^
TypeError: Cannot read property 'client_secret' of undefined
at authorize (/Users/prangyy/myApp/quickstart.js:32:43)
at processClientSecrets (/Users/prangyy/myApp/quickstart.js:21:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:404:3)
Change lines 34-36 in quickstart.js to:
var clientSecret = credentials.web.client_secret;
var clientId = credentials.web.client_id;
var redirectUrl = credentials.web.redirect_uris[0];
(There's an error where they've used credentials.installed instead of credentials.web, which is what shows up in the client_secrets.json file.)
Try checking your client_secret.json in the Node.js Quickstart.
It should contain clientID, auth_url, token_uri, auth_provider_x509_cert_url, client_secret, redirect_uris, javascript_origins.
{"web":{"client_id":"YOUR_CLIENT_ID","project_id":"google.com:my-project-1231","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"YOUR_CLIENT_SECRET","redirect_uris":["YOUR_REDIRECT"],"javascript_origins":["YOUR_JAVA_ORIGIN"]}}
if not yet, follow this to get your client_secret.json file
Use this wizard to create or select a project in the Google Developers Console and automatically turn on the API. Click Continue, then Go to credentials.
At the top of the page, select the OAuth consent screen tab. Select an Email address, enter a Product name if not already set, and click the Save button.
Select the Credentials tab, click the Create credentials button and select OAuth client ID.
Select the application type Other, enter the name "Google Calendar API Quickstart", and click the Create button.
Click OK to dismiss the resulting dialog.
Click the file_download (Download JSON) button to the right of the client ID.
Move this file to your working directory and rename it client_secret.json.
I hope this helps. Goodluck :)
No need to modify the original code if you check 'Other' (as said in the tutorial) when you choose your Application type in the client ID creation page (step 4 of your pasted text)

IIS creating a web site

I'm trying to add a new web site on my IIS manager.
-> My site name is "teorikolarak.com"
-> Application pool is "DefaultAppPool"
-> Physical Path is "C:\inetpub\wwwroot\teorikolarak.com"
teorikolarak.com is a file and it contains "default.html" page.
When I click the Test Settings... button it does not return any error. Everyting seems to okey .
-> binding type: http
-> IP adress : 192.168.2.4
-> Port:80
-> HostName: www.teorikolarak.com
Also I updated hosts file. "192.168.2.4 teorikolarak.com"
Now, when I type the www.teorikolarak.com on address bar It can not found the site. Also, I typed the 192.168.2.4 on address bar, default IIS7 page is opening. why is it happens? why my default.html file doesnt appears on my browser?
Windows7 & IIS7
Click on the website in IIS Manager and then press the Explore button in the Actions panel. Do you see your default.html file? If so, double click on the "Default Document" feature (in the middle panel). Check to see if Default.html is listed as a valid default document. It probably is not. Click the Add... button in the Actions panel to add "default.html" as a valid default document. Now it should work.
can you try going to
http://teorikolarak.com/

System.Net.WebClient doesn't work with Windows Authentication

I am trying to use System.Net.WebClient in a WinForms application to upload a file to an IIS6 server which has Windows Authentication as
it only 'Authentication' method.
WebClient myWebClient = new WebClient();
myWebClient.Credentials = new System.Net.NetworkCredential(#"boxname\peter", "mypassword");
byte[] responseArray = myWebClient.UploadFile("http://localhost/upload.aspx", fileName);
I get a 'The remote server returned an error: (401) Unauthorized', actually it is a 401.2
Both client and IIS are on the same Windows Server 2003 Dev machine.
When I try to open the page in Firefox and enter the same correct credentials as in the code, the page comes up.
However when using IE8, I get the same 401.2 error.
Tried Chrome and Opera and they both work.
I have 'Enable Integrated Windows Authentication' enabled in the IE Internet options.
The Security Event Log has a Failure Audit:
Logon Failure:
Reason: An error occurred during logon
User Name: peter
Domain: boxname
Logon Type: 3
Logon Process: ÈùÄ
Authentication Package: NTLM
Workstation Name: boxname
Status code: 0xC000006D
Substatus code: 0x0
Caller User Name: -
Caller Domain: -
Caller Logon ID: -
Caller Process ID: -
Transited Services: -
Source Network Address: 127.0.0.1
Source Port: 1476
I used Process Monitor and Fiddler to investigate but to no avail.
Why would this work for 3rd party browsers but not with IE or System.Net.WebClient?
I have seen a similar issue, where the Integrated / NTLM security will only work if you are accessing the host by machine name or localhost. In fact, it is a [poorly] document feature in Windows that is designed to protect against "reflection attacks".
Basically, you need to create a registry key on the machine that is trying to access the server, and whitelist the domain you are trying to hit. Each host name / FQDN needs to be on it's own line - there are no wildcards and the name must match exactly. From the KB Article:
Click Start, click Run, type regedit, and then click OK.
In Registry Editor, locate and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
Right-click MSV1_0, point to New, and then click Multi-String Value.
Type BackConnectionHostNames, and then press ENTER.
Right-click BackConnectionHostNames, and then click Modify.
In the Value data box, type the host name or the host names for the sites that are on the local computer, and then click OK.
Exit Registry Editor, and then restart the computer.
http://support.microsoft.com/kb/956158/en-us
Have you tried ...
new NetworkCredential( "peter", "password", "boxname" );
You might also try ...
var credCache = new CredentialCache();
credCache.Add( new Uri ("http://localhost/upload.aspx"),
"Negotiate",
new NetworkCredential("peter", "password", "boxname"));
wc.Credentials = credCache;
Also, according to this it may be that IIS is configured wrong. Try replacing "Negotiate" with "Basic" in the above and checking your IIS config for the website. There's also a bunch of possible causes here.
Try going into IE's options and explicitly add the site to the Intranet Zone. Then re-run the program. You should also not run the program from an administrator login. This may trigger the Enhanced Security Configuration for Internet Explorer.
It could explain why you can hit the site with Firefox and Opera, but not with IE or WebClient.
Without knowing your IIS deployment, and assuming that you have the correct authorization rules for upload set in IIS (e.g. the right allow* ACL's on the right dirs you are trying to upload content to, etc), first thing I would try is to set UseDefaultCredentials to true instead of explicitly set Credential. (Maybe you think you are accessing the server with the Credentials you are setting but that's not the case? That would be possible if this works.)
This is a very common scenario, so I would focus on IIS authorization rules for the directory in which you are trying to upload the file, the actual ACL's on that directory. For ex. is your site impersonating or not? if it is, then you have to have actual ACL's on that dir, otherwise whatever account app pool is running on.

Resources