In this blog, I will explain how to send an estimate from .NET MVC web application using SDK.
Before using any Quickbooks online API we need access token, if you don’t know how to get access token then you can find it here.
An estimate will be sent to the email. if the email address already set in estimate Email or it already exists in estimate’s “Estimate.BillEmail.Address” then it will be sent to that email else we have to give a particular email on which we have to send an estimate.
Below are a few steps to send an estimate,
public ActionResult SendEstimateById(string EstimateID) { try { OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(Access_token); // Create a ServiceContext with Auth tokens and realmId ServiceContext serviceContext = new ServiceContext(RealmId, IntuitServicesType.QBO, oauthValidator); serviceContext.IppConfiguration.MinorVersion.Qbo = "23"; serviceContext.IppConfiguration.BaseUrl.Qbo = QboBaseUrl; string EXISTING_ESTIMATE_QUERYBYID = string.Format("select * from Estimate where id = '{0}'", EstimateID); var queryService = new QueryService<Estimate>(serviceContext); Estimate objEstimateFound = queryService.ExecuteIdsQuery(EXISTING_ESTIMATE_QUERYBYID).FirstOrDefault<Estimate>(); //If Estimate found on Quickbooks online if (objEstimateFound != null) { DataService dataService = new DataService(serviceContext); if (objEstimateFound.BillEmail != null) { var SentPDF = dataService.SendEmail<Estimate>(objEstimateFound); ViewBag.IsSuccess = true; } else { //if you want to then, you can set ToEmail from database or somewhere else String ToEmail = "tabishzrangrej.vision@gmail.com"; var SentPDF = dataService.SendEmail<Estimate>(objEstimateFound, ToEmail); ViewBag.IsSuccess = true; } } return View(); } catch (IdsException ex) { return View(); } catch (Exception ex) { return View(); } }
@{ ViewBag.Title = "SendEstimateById"; } <h2>SendEstimateById</h2> @if (ViewBag.IsSuccess != null && ViewBag.IsSuccess == true) { <div class="row"> <label class="label label-success"> Estimate Sent Successfully </label> </div> }
You can also set a send email link in the list view of the estimate. if you don’t know how to get estimates from Quickbooks Online you can find it here.
@model List<Intuit.Ipp.Data.Estimate> @{ ViewBag.Title = "GetAllEstimate"; } <h2>Quickbooks online Estimate List</h2> <div> <table class="table table-bordered"> <tr> <th>QBO ID</th> <th>Estimate Number</th> <th>Due Date</th> <th>Customer</th> <th>Total Amount</th> <th style="text-align:center;">Download</th> <th style="text-align:center;">Send Email</th> </tr> @foreach (var item in Model) { <tr> <td>@item.Id</td> <td>@item.DocNumber</td> <td>@item.TxnDate.ToString("MM/dd/yyyy")</td> <td>@item.CustomerRef.name</td> <td>@item.TotalAmt</td> <td style="text-align:center;"><a href="@Url.Action("GetEstimatePdfById", "Home", new { EstimateID = item.Id })" target="_blank"><img src="~/Content/Images/downloadICON.png" height="25" width="25" /></a></td> <td style="text-align:center;"><a href="@Url.Action("SendEstimateById", "Home", new { EstimateID = item.Id })" target="_blank"><img src="~/Content/Images/SendImageICON.png" height="25" width="25" /></a></td> </tr> } </table> </div>
In the above code, on click of send email icon estimate will be sent.
OUTPUT:
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular