Hi , i developed a microbot which is working like a outlook acitvity who’s funstion is to send mail with attachment. It is developed in visual studio who’s code i have shared below. i am able to test run the bot and send the mail through outlook with help of this microbot easily in AE version 17.5.5, but when i execute the same in version 18.0 its shows test run successfull but mail is not being sent. Please help with this issue.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;
using System.Threading.Tasks;
using SE.Core.Automation.Interfaces;
using SE.Core.Automation.Models;
using SE.Core.Automation.Models.Common;
using Outlook = Microsoft.Office.Interop.Outlook;
namespace Outlook_Microbot
{
public class Micorbot : IAECodePackage
{
private string InputMailID;
private string InputMailBody;
private string InputMailSubject;
private string InputMailAttachment;
private int errCode;
private string errDesc;
private bool isProcessCompleted;
public event EventHandler ExecutionCompleted;
[ArgumentDirection(Direction = DirectionType.Input)]
public string inputmailID
{
get { return InputMailID; }
set { InputMailID = value; }
}
[ArgumentDirection(Direction = DirectionType.Input)]
public string inputmailbody
{
get { return InputMailBody; }
set { InputMailBody = value; }
}
[ArgumentDirection(Direction = DirectionType.Input)]
public string inputmailsubject
{
get { return InputMailSubject; }
set { InputMailSubject = value; }
}
[ArgumentDirection(Direction = DirectionType.Input)]
public string inputmailattachment
{
get { return InputMailAttachment; }
set { InputMailAttachment = value; }
}
[ArgumentDirection(Direction = DirectionType.Output)]
public int ErrCode
{
get { return errCode; }
set { errCode = value; }
}
[ArgumentDirection(Direction = DirectionType.Output)]
public string ErrDesc
{
get { return errDesc; }
set { errDesc = value; }
}
[ArgumentDirection(Direction = DirectionType.Output)]
public bool IsProcessCompleted
{
get { return isProcessCompleted; }
set { isProcessCompleted = value; }
}
public void Execute(StudioContext context)
{
try
{
// Create the Outlook application.
Outlook.Application oApp = new Outlook.Application();
// Create a new mail item.
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
// Set HTMLBody.
//add the body of the email
oMsg.HTMLBody = InputMailBody;
//Add an attachment.
String sDisplayName = "MyAttachment";
int iPosition = (int)oMsg.Body.Length + 1;
int iAttachType = (int)Outlook.OlAttachmentType.olByValue;
//now attached the file
Outlook.Attachment oAttach = oMsg.Attachments.Add(InputMailAttachment, iAttachType, iPosition, sDisplayName);
//Subject line
oMsg.Subject = InputMailSubject;
// Add a recipient.
Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
// Change the recipient in the next line if necessary.
Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(InputMailID);
oRecip.Resolve();
// Send.
oMsg.Send();
// Clean up.
oRecip = null;
oRecips = null;
oMsg = null;
oApp = null;
}//end of try block
catch (Exception ex)
{
errCode = 100;
isProcessCompleted = false;
errDesc += "Message: " + ex.Message + Environment.NewLine + "Inner Exception: " + ex.InnerException + Environment.NewLine;
}//end of catch
finally
{
ExecutionCompleted(this, null);
}
}
}
}