How to send attachment larger than 3MB using Microsoft Office 365 Activity

Hi guys,

I have noticed that when sending email with attachment larger than 3MB in Microsoft office 365, it throws below error. If I send less than 3MB works fine.

I have declared a variable and assigned it a folder path

Attachments_Collection = System.IO.Directory.GetFiles("C:\Users\user1\Documents\New folder")

Then added the variable in Collection at Send mail activity

Kindly assist if there is a way of sending attachment larger than 3MB using Office 365.

==================

UPDATES:

==================
I have tried using HTTP request (Postman) and added these two Header lines and it worked. Is there a way to add these in Microsoft Office 365 Activity?

Headers.Add("Connection", "Keep-Alive");
Headers.Add("Keep-Alive", "3600");

@wilbardmtei

3MB is pretty less for the file aize limit alao to be hit…can you try increasing the timeout or change the package version please

These are the limits fyi

Cheers

Hi @Anil_G , Thanks for your response. I have increased timeout to 600000 but still getting same error.

ERROR:

Send Mail: Code: generalException
Message: An error occurred sending the request.

@wilbardmtei

Please check the inner exception details from locas panel and share that…as that would contain the exact exception details

Cheers

Hi @Anil_G Below is detailed error.

Microsoft.Graph.ServiceException: Code: generalException
Message: An error occurred sending the request.
 ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host.
	--- End of inner exception stack trace ---
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token)
   at System.Net.Http.HttpConnection.ReadAsync(Memory`1 destination)
   at System.Net.Http.HttpConnection.RawConnectionStream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
   at System.Net.Security.SslStream.EnsureFullTlsFrameAsync[TIOAdapter](TIOAdapter adapter)
   at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](TIOAdapter adapter, Memory`1 buffer)
   at System.Net.Http.HttpConnection.<CheckUsabilityOnScavenge>g__ReadAheadWithZeroByteReadAsync|44_0()
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
	--- End of inner exception stack trace ---
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at Microsoft.Graph.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Graph.RetryHandler.SendAsync(HttpRequestMessage httpRequest, CancellationToken cancellationToken)
   at Microsoft.Graph.CompressionHandler.SendAsync(HttpRequestMessage httpRequest, CancellationToken cancellationToken)
   at Microsoft.Graph.AuthenticationHandler.SendAsync(HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at Microsoft.Graph.SimpleHttpProvider.SendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
	--- End of inner exception stack trace ---
   at Microsoft.Graph.SimpleHttpProvider.SendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
   at Microsoft.Graph.SimpleHttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
   at Microsoft.Graph.BaseRequest.SendRequestAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
   at Microsoft.Graph.BaseRequest.SendAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
   at UiPath.Shared.Services.Graph.Mail.Extensions.GraphServiceClientExtensions.SendDraftAsync(GraphServiceClient graphClient, String draftId, String address, CancellationToken cancellationToken)
   at UiPath.MicrosoftOffice365.Services.GraphServiceClientProxy.SendMailAsync(SendMailRequest request, CancellationToken cancellationToken)
   at UiPath.MicrosoftOffice365.Activities.Mail.SendMail.ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
   at UiPath.Shared.Activities.AsyncTaskCodeActivityImplementation.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
   at UiPath.Shared.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
   at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
   at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Hi @Anil_G

I have tried using HTTP request (Postman) and added these two Header lines and it worked. Is there a way to add these in Microsoft Office 365 Activity?

Headers.Add("Connection", "Keep-Alive");
Headers.Add("Keep-Alive", "3600");

@wilbardmtei

Please check this…from the remote server/host the connection is not alive…

I believe using office 365 we do not have direct option to keep alive…can you please change your office 365 version and give a try…ideally increasing timeout should keep the connection alive for a while

Alternately please delete the pckage from .nuget folder and re open the project that should download a fresh copy of the package

Cheers

Hi @Anil_G , Thanks for the support. I tried downloading fresh copy but didn’t work, Then I updated UiPath.Mail.Activities to version 1.18.2 and worked.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.