Adding attachment to Outlook email with VSTO - email

I'm trying to develop a custom attach file button that will show on the ribbon of a new, blank email. ( I would like to insert the button in the highlighted section)
This article from MSDN shows how to attach a file and create the email, which is useful but not exactly what I'm after. Is there any documentation on adding attachments to emails which are already open?

Application.ActiveInspector.CurrentItem.Attachments.Add

I was in the OfficeRibbon context so I ended up using the following code:
var item = this.Context as Outlook.Inspector;
var mailItem = item.CurrentItem as Outlook.MailItem;
mailItem.Attachments.Add(attachment.Location, Outlook.OlAttachmentType.olByValue, 1, attachment.FileName);

Related

How to show related email on popup composeMailData - Vtiger

I have a custom module, in this module there is a field related to the account, then I create an email send button on the detail page, how can when the compose mail popup is displayed, the email of this account is added automatically.
EditView
DetailView (compose mail popup)
You need to put that logic in your view controller. Take vtigercrm/modules/Vtiger/views/ComposeEmail.php as an example and create vtigercrm/modules/YourCustomModule/views/ComposeEmail.php
You need to do something similar to this when processing the request:
$accountId = $request->get('accountid');
$account = Vtiger_Record_Model::getInstanceById($accountId);
$viewer = $this->getViewer($request);
$viewer->assign('TO', $account->get('email'));

Assign Outlook Categories to a RibbonMenu with buttons

I am currently creating a Outlook Add-in and need to include the Outlook Catagorize Menu to my add-in.
With this Foreach I´m Creating and adding the Buttons manually into the "Kategorisieren"-RibbonMenu and naming them the same as the catagory names. Now I´m trying to copy the color-images of the categories to the button Image which works by assigning them with the right OfficeImageId. Nevertheless there are some catagories which colors are not described as OfficeImageIds, but rather like objects f. e. the color peach as an object of OlCategoryColor.OlCategoryColorPeach . The Problem is that I cant use them as the others by assigning them to the button.Image or OfficeImageId. How do I get these little Icons in the right Color next to my buttons.
The next Task would be assigning the Category to the Appointment by clicking on the right button.
Categories categories = Globals.TerminAddIn.Application.Session.Categories;
foreach (Category category in categories)
{
var button = this.Factory.CreateRibbonButton();
this.Kategorisieren.Items.Add(button);
button.Label = category.Name;
}
this.Kategorisieren.ControlSize = RibbonControlSize.RibbonControlSizeLarge;
this.Kategorisieren.OfficeImageId = "CategorizeMenu";
this.Kategorisieren.ShowImage = true;
I'd recommend using the ribbon XML with callbacks where you can define the button's images and labels. At any point in time, you can update the buttons list or change categories with colors. Read more about this approach in the Walkthrough: Create a custom tab by using Ribbon XML article.
When you customize the Ribbon UI by using callback procedures, for each of the callbacks the add-in implements, the responses are cached. For example, if an add-in writer implements the getImage callback procedure for a button, the function is called once, the image loads, and then if the image needs to be updated, the cached image is used instead of recalling the procedure. This process remains in-place until the add-in signals that the cached values are invalid by using the Invalidate method, at which time, the callback procedure is again called and the return response is cached.
The Fluent UI (aka Ribbon UI) is described in-depth in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

Drag text item in MS Word and create Content Control on mouse up event using Office JavaScript API

I am working on document automation solution through which user can drag item from custom text list (Task Pane) in to the Word document. I want to create add-in using Office.js.
In VSTO we are getting button down event where we have handle DragDrop:
if (MouseButtons == MouseButtons.Left)
{
strValue = (sender as Button).Text;
ThisAddIn.objWordApplication.Selection.SetRange(Cursor.Position.X, Cursor.Position.Y);
(sender as Button).DoDragDrop(" ", DragDropEffects.All);
oCC1 = ThisAddIn.objWordApplication.ActiveDocument.ContentControls.Add(Word.WdContentControlType.wdContentControlText);
oCC1.Range.Text = strValue;
}
Using Office.js, is it possible to achieve same thing from html container (Task pane) to Word document?
Thanks
You cannot handle button events in Office JS, but that's a good idea. Please suggest that at Developer User Voice.

create a button that emails the google sheet

In a google sheet that I've created, I have a place where I can put in an email address (in my sheet, it is actually located at cell I6. What I'm needing to do is create a script that will pull this email address out of I6 and then email the sheet to that email. I don't want to email every sheet, just that page that has the button I've created.
The main script I have thus far is:
function sendemail() {
MailApp.sendEmail("email address", "subject", "body");
}
Where it says "email address", I want it to pull the contents of cell I6. What is the coding to do this?
Any help is greatly appreciated.
Thanks,
Cliff
Since UI Service is deprecated, the only option is to assign a script to an image or drawing.
I've followed this tutorial - Google Spreadsheet Button to Run Scripts
Here is the code snippet:
function highFive(){
Browser.msgBox("High Five!");
}
Once I click the image this will happen:
Also in the tutorial, there is a snippet regarding sending an email with the button:
function email(){
var rng = SpreadsheetApp.getActiveSheet().getActiveRange()
var email = rng.getValues()[0];
GmailApp.sendEmail(email[0], email[1], email[2]);
}
Hope this helps.

Access VBA: Form command button to do something/call function

I have created a basic form in access that has a couple of buttons and text fields.
I want the button to do something along the lines of when I click it, it should bring up a browse file dialog and when I select a file, change the text field to the path of the file.
My question is how can I program this? Specifically, do I create a module that goes like?
sub command1_onClick()
..bla bla...
end sub
Or are forms programmed differently? How can I tie a function to a button?
You can add actions to the button. In the properties window of the button is an Event-Tab. Click on On Click and select Event Procedure. You are then taken to the VBA Editor (ALT+F11) into following procedure:
Private Sub Command1_Click()
End Sub
In that procedure, you can use an API call to open the standard file dialog:
API: Call the standard Windows File Open/Save dialog box
The TestIt function in above link shows you hove to open the dialog and get the path. You can set your textbox to that path like this:
Me!Text1 = strPath
strPath has to be populated with the path you get from the file dialog.
You will want to look at the file dialog property.
Dim fDialog As Office.FileDialog
MSDN File Dialog
The above shows an example that is performed on a button click
The example adds the selected file to a listbox, for your situation you would want to use a simple textbox instead of the listbox.
You may want to set AllowMultiSelect to false to ignore the looping part if you only want one item. (this would simplify the code in the example for you.
.AllowMultiSelect = false
I may be a lil rusty but then you would want to do something like this(someone edit or correct me if I am way off)
Assuming you used varFile
(Dim varFile As Variant)
Me.TextBox1.Text = varFile
EDIT: After encountering error
It seems the error can come froma few things. Check to make sure the reference is there.
Also you may need to add the Microsoft DAO 3.6 Object Library reference.
See the "More information" section of this Link (Hopefully 2002 is close enough to 2003)
. It may have a few more helpful tips if that doesn't solve the problem.