- Joined
- Oct 10, 2018
- Messages
- 1
- Reaction score
- 0
Hallo All thanks for your help
I have developed 2 addin applications for outlook with send method .
I want for the first to use this event
I have developed 2 addin applications for outlook with send method .
I want for the first to use this event
Code:
outlookApp.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(Forwarding_Click);
}
private void ItemSend_BeforeSend(object Item, ref bool Cancel)
{
Outlook.MailItem mailItem = (Outlook.MailItem) Item ;
if (mailItem != null)
but for the seconde is ribon button I want only send the forwarding mail without event ItemSend
private void Forwarding_Click(object sender, RibbonControlEventArgs e)
{
Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();
Selection selection = explorer.Selection;
object selectedItem = selection[1]; // Index is one-based.
MailItem mailItem = selectedItem as MailItem;
Microsoft.Office.Interop.Outlook.MailItem tosend = (Microsoft.Office.Interop.Outlook.MailItem)Globals.ThisAddIn.Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
tosend.Attachments.Add(mailItem);
tosend.To = "[email][email protected][/email]";
tosend.Subject = "test";
tosend.Body = "blah";
string message = "Email sent externally.This message you are attempting to" + "\n" +
" send has one or more external recipient.Are you sure you" + "\n" +
"want to send this message to external recipient(s)? Please" + "\n" +
"note that by sending this message, you should adhere with " + "\n" +
"the Bank Information Security Policy Please search for " + "\n" +
"Information Security Policy on the intranet Document Center";
string caption = "CA DataMinder Advisory Forward";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result;
// Displays the MessageBox.
result = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1,
MessageBoxOptions.RightAlign);
if (result == System.Windows.Forms.DialogResult.Yes)
{
// Closes the parent form.
tosend.send();
Cancel = false;
mailItem.Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olDiscard);
}
Cancel = true ;
}
.
Last edited by a moderator: