working on it ...

Filters

Explore Public Snippets

Sort by

Found 11k snippets matching: message

    public by marksimon232 modified Jun 10, 2014  252575  1  6  0

    translate messages with html tags - Code snippets for symfony 1.x

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xliff PUBLIC "-//XLIFF//DTD XLIFF//EN" "http://www.oasis-open.org/committees/xliff/documents/xliff.dtd">
    <xliff version="1.0">
        <file original="global" source-language="en" datatype="plaintext" date="2009-08-12T12:32:00Z">
            <header/>
            <body>
                ...
                <trans-unit>
                    <source>from %from_date%<br/>to %to_date%</source>
                    <target>de %from_date%<br/>até %to_date%</target>
                </trans-unit>
            </body>
        </file>
    </xliff>
    
    

    public by sherazam modified Jun 8, 2016  182268  1  5  0

    How to Delete Messages in Bulk or One by One from Outlook PST in .NET Apps

    This technical tip explains how .NET developers can Delete Messages from outlook PST. Add Messages to PST Files showed how to add messages to PST files. It is, of course, also possible to delete items (contents) from a PST file and it may also be desirable to delete messages in bulk. Items from a PST file can be deleted using the FolderInfo.DeleteC
    // Enter here the actual content of the snippet.            
    //Deleting Messages from PST Files
    
    //The code snippets below delete messages from a PST file's Sent subfolder.
    
    //[C# Code Sample]
    
    // Get the Sent items folder
    FolderInfo folderInfo = pst.GetPredefinedFolder(StandardIpmFolder.SentItems);
    MessageInfoCollection msgInfoColl = folderInfo.GetContents();
    foreach (MessageInfo msgInfo in msgInfoColl)
    {
        Console.WriteLine(msgInfo.Subject + ": " + msgInfo.EntryIdString);
        if (msgInfo.Subject.Equals("some delete condition") == true)
        {
            // Delete this item
            folderInfo.DeleteChildItem(msgInfo.EntryId);
            Console.WriteLine("Deleted this message");
        }
    }
     
    //[VB.NET Code Sample]
    
    ' Get the Sent items folder
    Dim folderInfo As FolderInfo = pst.GetPredefinedFolder(StandardIpmFolder.SentItems)
    Dim msgInfoColl As MessageInfoCollection = folderInfo.GetContents()
    For Each msgInfo As MessageInfo In msgInfoColl
    	Console.WriteLine(msgInfo.Subject & ": " & msgInfo.EntryIdString)
    	If msgInfo.Subject.Equals("some delete condition") = True Then
    		' Delete this item
    		folderInfo.DeleteChildItem(msgInfo.EntryId)
    		Console.WriteLine("Deleted this message")
    	End If
    Next msgInfo
    
    //Delete Items in Bulk from PST File
    
    //Aspose.Email API can be used to delete items in bulk from a PST file. This is achieved using the DeleteChildItems method which accepts a list of Entry ID items referring to the items to be deleted.
    
    //[C# Code Sample]
    
    using (PersonalStorage pst = PersonalStorage.FromFile(@"test.pst"))
    {
        FolderInfo inbox = pst.RootFolder.GetSubFolder("Inbox");
        
        // find messages having From = "someuser@domain.com" 
        PersonalStorageQueryBuilder queryBuilder = new PersonalStorageQueryBuilder();
        queryBuilder.From.Contains("someuser@domain.com");
        MessageInfoCollection messages = inbox.GetContents(queryBuilder.GetQuery());
        IList<string> deleteList = new List<string>();
        foreach (MessageInfo messageInfo in messages)
        {
            deleteList.Add(messageInfo.EntryIdString);
        }
        
        // delete messages having From = "someuser@domain.com"
        inbox.DeleteChildItems(deleteList);
    }
    
    //[VB.NET Code Sample]
    
    Using pst As PersonalStorage = PersonalStorage.FromFile("test.pst")
    	Dim inbox As FolderInfo = pst.RootFolder.GetSubFolder("Inbox")
    
    	' find messages having From = "someuser@domain.com" 
    	Dim queryBuilder As New PersonalStorageQueryBuilder()
    	queryBuilder.From.Contains("someuser@domain.com")
    	Dim messages As MessageInfoCollection = inbox.GetContents(queryBuilder.GetQuery())
    	Dim deleteList As IList(Of String) = New List(Of String)()
    	For Each messageInfo As MessageInfo In messages
    		deleteList.Add(messageInfo.EntryIdString)
    	Next
    
    	' delete messages having From = "someuser@domain.com"
    	inbox.DeleteChildItems(deleteList)
    End Using
    
    

    public by sherazam modified Jun 15, 2016  3168  2  5  1

    How to Copy Message from One Mailbox Folder to Another in .NET Apps

    This technical tip explains how .NET developers can Copy Message from one Mailbox folder to another. Aspose.Email API provides the capability to copy message from one mailbox folder to another. It allows copying a single as well as multiple messages using the CopyMessage and CopyMessages methods. The CopyMessages method provides the capability to c
    // Enter here the actual content of the snippet.     //Copying Multiple Messages From One Folder to Another
    
    //[C# Code Sample]
    
    using (ImapClient client = new ImapClient("exchange.aspose.com", "username", "password" ))
    {
        //create the destination folder
        string folderName = "EMAILNET-35242";
        if (!client.ExistFolder(folderName))
            client.CreateFolder(folderName);
    
        try
        {
            //Append a couple of messages to the server
            MailMessage message1 = new MailMessage(
                "asposeemail.test3@aspose.com",
                "asposeemail.test3@aspose.com",
                "EMAILNET-35242 - " + Guid.NewGuid().ToString(),
                "EMAILNET-35242 Improvement of copy method.Add ability to 'copy' multiple messages per invocation.");
            string uniqueId1 = client.AppendMessage(message1);
    
            MailMessage message2 = new MailMessage(
                "asposeemail.test3@aspose.com",
                "asposeemail.test3@aspose.com",
                "EMAILNET-35242 - " + Guid.NewGuid().ToString(),
                "EMAILNET-35242 Improvement of copy method.Add ability to 'copy' multiple messages per invocation.");
            string uniqueId2 = client.AppendMessage(message2);
    
            //verify that the messages have been added to the mailbox
            client.SelectFolder(ImapFolderInfo.InBox);
            ImapMessageInfoCollection msgsColl = client.ListMessages();
            foreach (ImapMessageInfo msgInfo in msgsColl)
                Console.WriteLine(msgInfo.Subject);
    
            //copy multiple messages using hte CopyMessages command
            client.CopyMessages(new string[] { uniqueId1, uniqueId2 }, folderName, true);
    
            //Verify that messages are copied to the destination folder
            client.SelectFolder(folderName);
            msgsColl = client.ListMessages();
            foreach (ImapMessageInfo msgInfo in msgsColl)
                Console.WriteLine(msgInfo.Subject);
        }
        finally
        {
            try {
                client.DeleteFolder(folderName);
            }
            catch { }
        }
    }
     
    //[VB.NET Code Sample]
    
    Using client As New ImapClient("exchange.aspose.com", "username", "password")
    	'create the destination folder
    	Dim folderName As String = "EMAILNET-35242"
    	If Not client.ExistFolder(folderName) Then
    		client.CreateFolder(folderName)
    	End If
    
    	Try
    		'Append a couple of messages to the server
    		Dim message1 As New MailMessage("asposeemail.test3@aspose.com", "asposeemail.test3@aspose.com", "EMAILNET-35242 - " + Guid.NewGuid().ToString(), "EMAILNET-35242 Improvement of copy method.Add ability to 'copy' multiple messages per invocation.")
    		Dim uniqueId1 As String = client.AppendMessage(message1)
    
    		Dim message2 As New MailMessage("asposeemail.test3@aspose.com", "asposeemail.test3@aspose.com", "EMAILNET-35242 - " + Guid.NewGuid().ToString(), "EMAILNET-35242 Improvement of copy method.Add ability to 'copy' multiple messages per invocation.")
    		Dim uniqueId2 As String = client.AppendMessage(message2)
    
    		'verify that the messages have been added to the mailbox
    		client.SelectFolder(ImapFolderInfo.InBox)
    		Dim msgsColl As ImapMessageInfoCollection = client.ListMessages()
    		For Each msgInfo As ImapMessageInfo In msgsColl
    			Console.WriteLine(msgInfo.Subject)
    		Next
    
    		'copy multiple messages using hte CopyMessages command
    		client.CopyMessages(New String() {uniqueId1, uniqueId2}, folderName, True)
    
    		'Verify that messages are copied to the destination folder
    		client.SelectFolder(folderName)
    		msgsColl = client.ListMessages()
    		For Each msgInfo As ImapMessageInfo In msgsColl
    			Console.WriteLine(msgInfo.Subject)
    		Next
    	Finally
    		Try
    			client.DeleteFolder(folderName)
    		Catch
    		End Try
    	End Try
    End Using
    
           

    public by dave83 modified Mar 27, 2014  2966  0  7  4

    Reading Messages from a Queue with a MessageConsumer in JMS

    The code shows how to read messages from a queue using a Message Consumer in java Java Message Service. MessageConsumer object is created from the Session object, defined as non-transacted and auto-acknowledged, invoking createConsumer method. Such method will bind the consumer to the queue defined via JNDI lookup table.
    //Creating a non-transacted, auto-acknowledged session
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    //Creating messageConsumer bound to destination queue
    MessageConsumer messageConsumer = session.createConsumer(destination);
    connection.start();
    		
    Message message;
    boolean end = false;
    //read
    while (!end)
    {
        message = messageConsumer.receive();
        String text;
        if (message instanceof TextMessage)
        {
            text = ((TextMessage) message).getText();
        }
        else
        {
            byte[] body = new byte[(int) ((BytesMessage) message).getBodyLength()];
            ((BytesMessage) message).readBytes(body);
            text = new String(body);
        }
        if (text.equals("EXIT"))
        {
            System.out.println("Received exit message " + text);
            end = true;
        }
        else
        {
            System.out.println("Received  message:  " + text);
        }
    }
    //Tear down connection
    connection.close();

    public by dave83 modified Mar 27, 2014  2623  1  7  4

    How to create an asynchronous MessageListener in JMS

    This code is an example of Java Message Service message listener implementation. It shows how to create an asynchronous MessageListener, in order to receive message asynchronously as they are delivered to the message consumer. The client needs to create a message listener that implements the MessageListener interface. The MessageListener is as
    //Import the JMS API classes.
    import javax.jms.*;
    
    public class HelloWorldMessage implements MessageListener {
    	public void onMessage(Message message) {
    		/* Unpack and handle the messages received */
    		String newStockData = null;
    		/* Unpack and handle the messages received */
    		try {
    			newStockData = ((TextMessage) message).getText();
    		} catch (JMSException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		if (newStockData != null) {
    			/* Logic related to the data */
    		}
    	}
    }

    public by sherazam modified May 11, 2016  2257  0  5  0

    How to Create/Format Forward & Reply Email Messages inside .NET Apps

    This technical tip explains how .NET developers can Create the Forward & Reply Email Messages inside .NET Applications using Aspose.Email for .NET. Aspose.Email API provides the capability of creating and formatting the forward and reply messages. The ReplyMessageBuilder and ForwardMessageBuilder classes of the API are used to create the Reply and
    // Enter here the actual content of the snippet.            
    // Creating Reply Message
    
    //[C# Code Sample]
    
    MapiMessage originalMsg = MapiMessage.FromFile("original.msg");
    
    ReplyMessageBuilder builder = new ReplyMessageBuilder();
    builder.ReplyAll = true;
    builder.AdditionMode = OriginalMessageAdditionMode.Textpart;
    builder.ResponseText = "<p><b>Dear Friend,</b></p> I want to do is introduce my co-author and co-teacher. <p><a href=\"www.google.com\">This is a first link</a></p><p><a href=\"www.google.com\">This is a second link</a></p>";
    MapiMessage replyMsg = builder.BuildResponse(originalMsg);
    
    replyMsg.Save("reply.msg");
    
    //[VB.NET Code Sample]
    
    Dim originalMsg As MapiMessage = MapiMessage.FromFile("original.msg")
    
    Dim builder As New ReplyMessageBuilder()
    builder.ReplyAll = True
    builder.AdditionMode = OriginalMessageAdditionMode.Textpart
    builder.ResponseText = "<p><b>Dear Friend,</b></p> I want to do is introduce my co-author and co-teacher. <p><a href=""www.google.com"">This is a first link</a></p><p><a href=""www.google.com"">This is a second link</a></p>"
    Dim replyMsg As MapiMessage = builder.BuildResponse(originalMsg)
    
    replyMsg.Save("reply.msg")
    
    //Creating Forward Message
    
    //[C# Code Sample]
    
    ForwardMessageBuilder builder = new ForwardMessageBuilder();
    builder.AdditionMode = OriginalMessageAdditionMode.Textpart;
    MapiMessage forwardMsg = builder.BuildResponse(originalMsg);
    forwardMsg.Save("forward.msg");
    
    //[VB.NET Code Sample]
    
    Dim builder As New ForwardMessageBuilder()
    builder.AdditionMode = OriginalMessageAdditionMode.Textpart
    Dim forwardMsg As MapiMessage = builder.BuildResponse(originalMsg)
    forwardMsg.Save("forward.msg")
    
    

    public by Geometry modified Jul 31, 2016  99950  0  3  0

    Pass: Set the result Success to true

    Set the result Success to true Result to update Message indicating a possible warning Updated source
    C#
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    /// <summary>
    /// Set the result Success to true
    /// </summary>
    /// <param name="source">Result to update</param>
    /// <param name="message">Message indicating a possible warning</param>
    /// <returns>Updated source</returns>
    public static IOperationResult Pass(this IOperationResult source, string message = null)
    {
    	source.Success = true;
    	source.Message = message;
    	return source;
    }

    public by Geometry modified Jul 31, 2016  78312  0  4  0

    SerializeHeader: Block headers are sent in a headers packet in response to a getheaders message.

    Block headers are sent in a headers packet in response to a getheaders message. https://en.bitcoin.it/wiki/Protocol_specification#Block_Headers nodejs: https://github.com/zone117x/node-stratum-pool/blob/master/lib/blockTemplate.js#L85
    using System;
    using System.IO;
    using System.Text;
    using CoiniumServ.Jobs;
    using CoiniumServ.Utils.Extensions;
    using CoiniumServ.Utils.Helpers;
    using Gibbed.IO;
    
    /// <summary>
    /// Block headers are sent in a headers packet in response to a getheaders message.
    /// </summary>
    /// <remarks>
    /// https://en.bitcoin.it/wiki/Protocol_specification#Block_Headers
    /// </remarks>
    /// <example>
    /// nodejs: https://github.com/zone117x/node-stratum-pool/blob/master/lib/blockTemplate.js#L85
    /// </example>
    /// <param name="job"></param>
    /// <param name="merkleRoot"></param>
    /// <param name="nTime"></param>
    /// <param name="nonce"></param>
    /// <returns></returns>
    public static byte[] SerializeHeader(IJob job, byte[] merkleRoot, UInt32 nTime, UInt32 nonce)
    {
        byte[] result;
    
        using (var stream = new MemoryStream())
        {
            stream.WriteValueU32(nonce.BigEndian());
            stream.WriteValueU32(Convert.ToUInt32(job.EncodedDifficulty, 16).BigEndian());
            stream.WriteValueU32(nTime.BigEndian());
            stream.WriteBytes(merkleRoot);
            stream.WriteBytes(job.PreviousBlockHash.HexToByteArray());
            stream.WriteValueU32(job.BlockTemplate.Version.BigEndian());
    
            result = stream.ToArray();
            result = result.ReverseBytes();
        }
    
        return result;
    }

    public by sherazkhan modified Nov 18, 2015  2020  0  7  0

    How to Reads Outlook PST File & Displays Folder or Message Information in Android Apps

    This technical tip shows how to get the messages information from the Outlook PST file and display it inside .NET Applications. Previously we have discussed how to load an Outlook PST file and browse through its folders to get folder names and the number of messages in each folder. This topic explains how to read all the folders and subfolders in
    public void RetrievePSTFolderContents()
        {
            String strBaseFolder = Environment.getExternalStorageDirectory().getPath() + "/";                
            String pstFileName = strBaseFolder + "Outlook.pst";
    
            try
            {
                // Load the Outlook PST file
                PersonalStorage pst = PersonalStorage.fromFile(pstFileName);
    
                // Get the root folder
                FolderInfo folderInfo = pst.getRootFolder();
    
                // Call the recursive method to display the folder contents
                DisplayFolderContents(folderInfo, pst);
            }
            catch (Exception ex)
            {
                tx.setText(ex.getMessage());
            }
        }
    
        private static void DisplayFolderContents(FolderInfo folderInfo, PersonalStorage pst)
        {        // Display the folder name
            tx.setText(tx.getText() + "\n Folder: " + folderInfo.getDisplayName());
            // Display information about messages inside this folder
            MessageInfoCollection messageInfoCollection = folderInfo.getContents();
            for (int i = 0; i < messageInfoCollection.size(); i++)
            {
                MessageInfo messageInfo = (MessageInfo) messageInfoCollection.get(i);
                tx.setText(tx.getText() + "\n Subject: " + messageInfo.getSubject());
                tx.setText(tx.getText() + "\n Sender: " + messageInfo.getSenderRepresentativeName());
                tx.setText(tx.getText() + "\n To: " + messageInfo.getDisplayTo());
                tx.setText(tx.getText() + "\n CC: " + messageInfo.getDisplayCC());
                tx.setText(tx.getText() + "\n EntryID: " + messageInfo.getEntryIdString());
            }
    
            // Call this method recursively for each subfolder
            if (folderInfo.hasSubFolders() == true)
            {
                for (int i = 0; i < folderInfo.getSubFolders().size(); i++)
                {
                    FolderInfo subfolderInfo = (FolderInfo) folderInfo.getSubFolders().get(i);
                    DisplayFolderContents(subfolderInfo, pst);
                }
            }
        }
              

    public by FMXExpress modified Nov 13, 2014  9297  95  7  1

    Non Blocking Message Dialog For Delphi XE7 Firemonkey

    MessageDlg(‘Do you want to press yes or no?’, System.UITypes.TMsgDlgType.mtInformation,
      [System.UITypes.TMsgDlgBtn.mbYes, System.UITypes.TMsgDlgBtn.mbNo], 0,
        procedure(const AResult: TModalResult)
        begin
          case AResult of
            { Detect which button was pushed and show a different message }
            mrYes:
                begin
                // pressed yes
                end;
            mrNo:
                begin
                // pressed no
                end;
          end;
        end
      );
    // code here would get executed right away
    • Public Snippets
    • Channels Snippets