Hot answers tagged

5

If you want to customize the sender email address, then you cannot use SPUtility.SendEmail -- you'll have to use the System.Net.Mail framework classes. Under the covers, SPUtility calls a method named "RemoveFriendlyNameFromEmailAddress" :(


5

Might I suggest switching to using the System.Net.Mail.MailMessage object instead of SPUtility. SPUtility.SendEmail is a good shortcut but, as you've seen, you lose a lot of control over how the message is sent and formatted. The MailMessage object gives you that back but does require just a tiny bit more work. To answer your specific question, the ...


5

There is no possibility to send Attachments using this method. But you can use of SPAdministrationWebApplication to get the SMTP server details. Here is the sample code: //Get the Sharepoint SMTP information from the SPAdministrationWebApplication string smtpServer = SPAdministrationWebApplication.Local.OutboundMailServiceInstance .Server.Address; string ...


5

The default SPUtility, SendMail functionality in SharePoint is limited. And you can only send emails to people who are known within the site collection. If you only want to send email to people within site collection, then make sure you use EnsureUser() to check the availibility in site collection. Snippet: private void SendEmail(ClientContext ...


3

@Pradip already mentioned that it is not possible to send email to the external people using Utility so can consider System.Net.Mail to serve your purpose. MailAddress from = new MailAddress("jane@contoso.com", "Jane " + (char) 0xD8 + " Clayton", System.Text.Encoding.UTF8); MailAddress to = new MailAddress("ben@contoso.com"); MailMessage message = new ...


3

public static bool SendEmail( SPWeb web, bool fAppendHtmlTag, bool fHtmlEncode, string to, string subject, string htmlBody) You should set the parameters: fAppendHtmlTag true to append an HTML tag to the message; otherwise, false. fHtmlEncode true to encode the message and replace characters in HTML tags with entities; ...


3

This is not an ideal solution, however if your code works when there is an SPContext, you can create a fake SPContext when it does not exist: using (var site = new SPSite("url")) { using (var web = site.OpenWeb()) { HttpContext newContext = null; if (HttpContext.Current == null) { var request = new HttpRequest("", ...


3

SPUtility.SendEmail() is not available in a sandbox solution. You can use the SendEmail activity in a SharePoint Designer Workflow to accomplish your task.


3

I don't know of anything in the Client Object Model that lets you do this directly, but if you don't want to have to deploy a custom web service, you could probably make a list with a simple workflow that sends an email, and then just have your web part put an entry in the list and make sure it contains the columns you'll need to build the email message in ...


2

SpContext.CurrentWeb.Language always returns languages that is used for site creation, if you would like to change languages on your site dynamically you should use `Thread.CurrentCulture.LCID'. If you would like to get this values in .aspx file, you should create module that deploys resources files to the GlobalResources folder. See this post how to do it. ...


2

SharePoint is extremely large about the Url we pass it so even though the url isn't really to the site or to the list (but to a view) both constructor for SPSite and SPWeb.GetList accepts it: using (var site = new SPSite(url)) using (var web = site.OpenWeb()) { var list = web.GetList(url); // ID is now in list.ID; }


2

Matt, You can create an user control to handle this in code. You can then add the control to the master page. Take a look at these two examples and let me know if I can assist. Inject dynamic javascript using MasterPage Programmatically add JS/CSS to pages


2

This is the tag for Utilities registration on aspx page. <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>


2

Most probably the problem does not come from the SharePoint configuration, but from the SMTP relay you use. Do you use IIS 6.0 as the local SMTP? Does it then forward the email to an Exchange server or else? The local SMTP relay or the Exchange server configurations have to be investigated first.


1

In the newform.aspx, the content type id is passed in the querystring if it is other than the default content type chosen in the list. To find out with which content type the item is being created , then you can handle the querystring else you can find the default content type of the list to fill in your field. Remember , you still have to make a async query ...


1

Break up your Mission in smaller tasks, you allready started with alert() Ditch alert and learn to use F12 Developer Tools In Chrome you can use Snippets http://stackoverflow.com/questions/10470711/chrome-developer-tools-what-is-snippets-support That will execute any of your javascript on the current page and saves you from loading it in SharePoint As ...


1

Try following code var valoftxt1 = SPUtility.GetSPField('field1name').GetValue(); var valoftxt2 = SPUtility.GetSPField('field2name').GetValue(); var valoftxt3 = SPUtility.GetSPField('field3name').GetValue(); if (!valoftxt1 || !valoftxt2 || !valoftxt3) { return false; }


1

You may use a simple JavaScript to find whether the checkbox is checked, if yes, find the corresponding textbox and check if the textbox contains any value. Show an alert message to the users if there is no value. Given below a sample JS code, modify the code based on your HTML format <script type="text/javascript" language="javascript"> function ...


1

Here you go: For title: string myListTitle = SPUtility.GetLocalizedString("$Resources:core,announceList;", "core", web.Language); For Description: string myListDesc = SPUtility.GetLocalizedString("$Resources:core,announceList_Desc;", "core", web.Language);


1

In the end I just opted for a custom input form in SharePoint designer and ended up writing the jQuery in a CEWP to do the show / hide. I just could not find a way to reliably redirect with jQuery combined with the SPUtility.js Still SPUtility is a very handy set of js for SharePoint. jQuery in the end was: function hideColumn(c) { $(".ms-formlabel h3 ...


1

The reason is explained in the link you had given. "The .NET Framework HttpUtility encoding library does not encode all characters sufficiently. For example, SPHttpUtility in SharePoint encodes a single quotation mark as ' but .NET Framework HttpUtility does not encode the single quotation mark." Apart from that, there isn't much preference i ...


1

Create the custom Web service then use it in your application.


1

There's no such built-in functionality. In addition to two methods to achieve your goal from the similar thread provided by Falak Mahmood I can offer another one and easiest in my opinion. You can add an ASP.NET Ajax callback to your web part. Here's an example: http://ajaxzen.wordpress.com/tag/icallbackeventhandler/ Then you need only to call it from client ...


1

If the user is not in the User Information List, how would they have an associated SPUser object with a login etc.? If ResolvePrincipal() didn't return null here, wouldn't this break when you tried to access a property like you do here: SPUser user = properties.Web.EnsureUser(pi.LoginName); I think the short answer is no.


1

SharePoint can only work with Security Groups from Active Directory. The groups that are not working are most likely distribution groups.


1

(string)listitem["RichTextField"]; does return with html tags for me, turns out what I was missing was an additional header tag headers.Add("fAppendHtmlTag","True");



Only top voted, non community-wiki answers of a minimum length are eligible