Umbraco - how to add a custom notification? - events

I'm using Umbraco 4.6.2, and need to extend the default notifications it provides. For the sake of this question, let's say I am trying to add an "Unpublish" notification.
In \umbraco\presentation\umbraco\dialogs\notifications.aspx.cs it constructs the list of checkbx items shown to the user when opening the "Notifications" dialogue from the context menu.
I see that each Action has a ShowInNotifier property - how can I set this value to true for the UnPublish action?
Does this require modifying the core codebase, or is there a nice way I can gracefully extend Umbraco?
So after I have added this, users can subscribe to the UnPublish notification (am I missing any steps here?).
Will this automagically send notifications now?
I'm guessing not, so the next thing I have done is hooked the UnPublish event:
public class CustomEvents : ApplicationBase
{
public CustomEvents()
{
Document.AfterUnPublish += new Document.UnPublishEventHandler(Document_AfterUnPublish);
}
void Document_AfterUnPublish(Document sender, umbraco.cms.businesslogic.UnPublishEventArgs e)
{
var user = User.GetCurrent();
if (!string.IsNullOrEmpty(user.Email) && user.GetNotifications(sender.Path).Contains("UnPublish"))
{
//Send a notification here using default Umbraco settings, or, construct email and send manually:
string umbracoNotificationSenderAddress = ""; //How to get the address stored in umbracoSettings.config -> <notifications> -> <email>
//How to use the same subject/message formats used for other notifications? With the links back to the content?
string subject = "Notification of UnPublish performed on " + MyUtilities.GetFriendlyName(sender.Id);
string message = MyUtilities.GetFriendlyName(sender.Id) + " has just been unpublished.";
umbraco.library.SendMail(umbracoNotificationSenderAddress, user.Email, subject, message, true);
}
}
}
So the bits of that code that are not real/I need some pointers on:
Is that the correct way for checking if a user is subscribed to a particular notification?
How can I send a notification using the default umbraco settings? (e.g. generate an email just like the other notifications)
If that is not possible and I must construct my own email:
How do I get the from email address stored in umbracoSettings.config that
How can I copy the formatting used by the default Umbraco notifications? Should I manually copy it or is there a nicer way to do this (programmatically).
Any help (or even just links to relevant examples) are appreciated :>

My colleague got this working.
Create a class that overrides the action you wish to have notifications for.
You can see all the actions in /umbraco/cms/Actions
public class ActionUnPublishOverride : umbraco.BusinessLogic.Actions.ActionUnPublish, IAction
{
... see what the other actions look like to find out what to put in here!
In the overridden class, you will have a public char Letter. Set this to match the event to hook into. You can find the letters each event has in the database.
Set the public bool ShowInNotifier to true.
That's it!

I've got this working on Umbraco 4.7 by using the UmbracoSettings class:
http://www.java2s.com/Open-Source/CSharp/Content-Management-Systems-CMS/umbraco/umbraco/businesslogic/UmbracoSettings.cs.htm
umbraco.library.SendMail(umbraco.UmbracoSettings.NotificationEmailSender, newMember.Email, "email subject", "email body", false);

Related

Properly implement In-App Updates in App Center?

I am reading this documentation/article from Microsoft on how to Distribute Mobile apps with app center. The problem is I really don't understand how to implement this. I have a app on app center (Android) I want to implement mandatory update so that I can eliminate the bugs of the previous version. I tried to distribute the app with mandatory update enabled and it is not working. How can I fix this?
https://learn.microsoft.com/en-us/appcenter/distribution/
Here is what I did I added this code on my App.xaml.cs (XAMARIN FORMS PROJECT):
protected override void OnStart ()
{
AppCenter.Start("android={Secret Code};", typeof(Analytics), typeof(Crashes), typeof(Distribute));
Analytics.SetEnabledAsync(true);
Distribute.SetEnabledAsync(true);
Distribute.ReleaseAvailable = OnReleaseAvailable;
}
bool OnReleaseAvailable(ReleaseDetails releaseDetails)
{
string versionName = releaseDetails.ShortVersion;
string versionCodeOrBuildNumber = releaseDetails.Version;
string releaseNotes = releaseDetails.ReleaseNotes;
Uri releaseNotesUrl = releaseDetails.ReleaseNotesUrl;
var title = "Version " + versionName + " available!";
Task answer;
if (releaseDetails.MandatoryUpdate)
{
answer = Current.MainPage.DisplayAlert(title, releaseNotes, "Download and Install");
}
else
{
answer = Current.MainPage.DisplayAlert(title, releaseNotes, "Download and Install", "Ask Later");
}
answer.ContinueWith((task) =>
{
if (releaseDetails.MandatoryUpdate || (task as Task<bool>).Result)
{
Distribute.NotifyUpdateAction(UpdateAction.Update);
}
else
{
Distribute.NotifyUpdateAction(UpdateAction.Postpone);
}
});
return true;
}
And here is what I added on my MainActivity.cs(ANDROID PROJECT):
AppCenter.Start("{Secret Code}", typeof(Analytics), typeof(Crashes), typeof(Distribute));
Looking at this App Center documentation here for Xamarin Forms -
You can customize the default update dialog's appearance by implementing the ReleaseAvailable callback. You need to register the callback before calling AppCenter.Start
It looks like you need to swap your current ordering to get in-app updates working.
There could be a lot of different reasons as to why they are not working. As you can see in the Notes here and here,
Did your testers download the app from the default browser?
Are cookies enabled for the browser in their settings?
Another important point you'll read in the links, is that the feature is only available for listed distribution group users. It is not for all your members. You could use a simple version checker for your purpose instead or you could use a plugin.

outlook vsto sending mail

I've been struggling with this for a while now and I can't get an answer anywhere.
I made an outlook add in which has a ribbon and two buttons, The one button opens up a mailitem where you can compose your mail and then the 2nd button sends the mail.
In the background it takes all of the recipients and adds it to the bcc field and sends the mail in batches for instance if there are 100 recipients it will send to 25 people at time.
So my problem is that it works perfectly on the developer PC but the send button doesn't work on the end user PC. The add in loads registries are fine and it targets the right .Net framework everything!
private void CreateEmailItem(Outlook.Recipient strRecipientAddressTo)
{
string strFilePath = #"c:\temp\OutlookAttachments";
string[] strFiles = Directory.GetFiles(strFilePath);
bool bFileExists = Directory.Exists(strFilePath);
Outlook.MailItem eMail = (Outlook.MailItem)
Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olMailItem);
Outlook.MailItem mailItem = Globals.ThisAddIn.Application.ActiveInspector().CurrentItem as Outlook.MailItem;
eMail.Subject = mailItem.Subject;
eMail.BCC = mailItem.To;
eMail.Body = mailItem.Body;
if (bFileExists)
{
foreach (string file in strFiles)
{
File.SetAttributes(file, FileAttributes.Normal);
eMail.Attachments.Add(file);
}
}
((Outlook._MailItem)eMail).Send();
}
When the send button on the ribbon is clicked this method is called, but on end user the button just doensn't fire .. can this be permissions ? or any advice would be very much appreciated !!!!
It is hard to suggest there but did you add any logging there. There can be chances that you are getting some crash in following line..
email.Attachments.Add(file)
And thats why it is not reaching until send statement. You can check the event logs on user's system as well. They might help you.

Raw Notification Handling in UI inside my App in Windows Phone 8

Can some one help me out in showing a TextBox in all screens after parsing a Raw Notification data. I'm successfully able to show this data on a MessageBox like the code below but unable to show in TextBox and I want this TextBox to be called from any screen in my app. How can I do this?
public void PushChannel_HttpNotificationReceived(object sender, HttpNotificationEventArgs e)
{
string message;
using (System.IO.StreamReader reader = new System.IO.StreamReader(e.Notification.Body))
{
message = reader.ReadToEnd();
}
Debug.WriteLine("This is a "+message);
var RawNotification = (RawData)serializer.ReadObject(e.Notification.Body);*/
Dispatcher.BeginInvoke(() =>
MessageBox.Show(String.Format("Received Notification {0}:\n{1}",
DateTime.Now.ToShortTimeString(), message))
);
}
I did this for one of my app. I Don't know if this is correct way of doing it or not but it solved my purpose.
1) First Create a UserControl in whatever look and feel you want to have. Make sure you create a Public Variable that will accept String ( In this case your Message )
2) Create a method in App.xaml.cs with String parameter ( To Pass your message string ). Withing the Method, Do a Dispatcher which will call a Messagebox with Content as the usercontrol. When invoking the UserControl, Pass your message as parameter.
Now whenerver or wherever you want to display a message, Use this method from App.xaml.cs and then you can create this textbox update.

Issue with SentOnBehalfOfName

i'm stack with Outlook issue where i want to change Email Sender. I want to send all emails from Outlook with one sender. When i change sender from Outlook it works fine but when i change it from Outlook plugin it's not work. I'm using following code:
private void adxOutlookEvents_ItemSend(object sender, ADXOlItemSendEventArgs e)
{
if (e.Item is MailItem)
{
MailItem mail = e.Item as MailItem;
mail.SentOnBehalfOfName = "UserName";
mail.Save();
return;
}
}
But nothing happens. I don't see any error or exception but email come to Outlook with old sender. Can you please help me with that?
UPDATED: The way how i fix it. We cant use property "SentOnBehalfOfName" Outlook handle it incorect. Except it you should use "Sender" property:
mail.Recipients.Add(mail.SentOnBehalfOfName);
mail.Recipients.ResolveAll();
var adressEntry = mail.Recipients[mail.Recipients.Count].AddressEntry;
mail.Recipients.Remove(mail.Recipients.Count);
mail.Sender = adressEntry;
Are you sending through Exchange and want to send on behalf of another user (do you have the permission?) or trying to send through a particular POP3/SMTP account (use MailItem.SendUsingAccount property)?

Saving/Organizing/Searching Outlook E-mail outside of Outlook

My company requires me to use Outlook for my E-mail. Outlook does virtually nothing the way I want to do it and it frustrates me greatly. (I'm not trying to start a flame war here, it must do exactly what thousands of CEO's want it to do, but I'm not a CEO.)
I would like to be able to automatically extract the thousands of E-mails and attachments currently in my Outlook account and save them in my own alternative storage format where I can easily search them and organize them the way I want. (I'm not requesting suggestions for the new format.)
Maybe some nice open source program already can do this... that would be great. Please let me know.
Otherwise, how can I obtain the message content and the attachments without going through the huge collection manually? Even if I could only get the message content and the names of the attachments, that would be sufficient. Is there documentation of the Outlook mail storage format? Is there a way to query Outlook for the data?
Maybe there is an alternative approach I haven't considered?
My preferred language to do this is C#, but I can use others if needed.
Outlook Redemption is the best thing currently to use that I have found. It will allow you to get into the messages and extract the attachments and the message bodies. i am using it now to do just that.
Here is some code I use in a class. I included the constructor and the processing function I use to save off the attachments. I cut out the code that is specific to my needs but you can get an idea of what to use here.
private RDOSession _MailSession = new RDOSession();
private RDOFolder _IncommingInbox;
private RDOFolder _ArchiveFolder;
private string _SaveAttachmentPath;
public MailBox(string Logon_Profile, string IncommingMailPath,
string ArchiveMailPath, string SaveAttPath)
{
_MailSession.Logon(Logon_Profile, null, null, true, null, null);
_IncommingInbox = _MailSession.GetFolderFromPath(IncommingMailPath);
_ArchiveFolder = _MailSession.GetFolderFromPath(ArchiveMailPath);
_SaveAttachmentPath = SaveAttPath;
}
public void ProcessMail()
{
foreach (RDOMail msg in _IncommingInbox.Items)
{
foreach (RDOAttachment attachment in msg.Attachments)
{
attachment.SaveAsFile(_SaveAttachmentPath + attachment.FileName);
}
}
if (msg.Body != null)
{
ProcessBody(msg.Body);
}
}
}
edit:
This is how I call it and what is passed
MailBox pwaMail = new MailBox("Self Email User", #"\\Mailbox - Someone\Inbox",
#"\\EMail - Incomming\Backup", #"\\SomePath");
If you want to extract your e-mails take a look at
Outlook Email Extractor
at codeproject
http://69.10.233.10/KB/dotnet/OutlookEmailExtractor.aspx
rob
www.filefriendly.com

Resources