How to save Outlook floating emails and attachments

Hi, there.

I am opening some outlook emails posted in a website. I thought the SMTP activities Save Mail Message and Save Attachments would help, but they can’t be linked with the floating email message I opened from the website, it seems it need an email account, but these emails are not in a email server, they are posted in a website.

I also tried Attached Window and Click activities to save the email and the attachments, and they work well in the foreground, but when I change it so Simulate Click or Send Windows Messages for them to work in the background, it fails.

I need to be able to run it in the background so it can be run from the orquestrator. Since the background option don’t work I need to try to use some activities to save the email and save the attachment.

Please reply, UIPath or somebody who has a solution,

image

Hello @Edgar_Estuardo_Rodriguez ,

This won’t work with SMTP since it is a protocol for sending mail, as well as you won’t be able to retrieve mail using IMAP/POP if it is not located on an email server.

From what I understand you have saved email files, I’m going to assume they’re on .msg format, and they’re stored on a web server. Based on this assumption here is my approach:

  1. Download the email using HTTP/FTP —>refer to the administrator of the server to evaluate both possibilities.
  2. Extract the .msg file content with a script using Invoke Code, here’s a sample VB implementation I got from a popular external site
'This solution is presented as is, with no warranties. Troubleshoot as needed

Sub SaveOlAttachments()

Dim msg As Outlook.MailItem
Dim att As Outlook.Attachment
Dim strFilePath As String
Dim strAttPath As String

    'path for creating msgs
strFilePath = "C:\temp\"
    'path for saving attachments
strAttPath = "C:\temp1\"

strFile = Dir(strFilePath & "*.msg")
Do While Len(strFile) > 0
    Set msg = Application.CreateItemFromTemplate(strFilePath & strFile)
    If msg.Attachments.Count > 0 Then
         For Each att In msg.Attachments
             att.SaveAsFile strAttPath & att.FileName
         Next
    End If
    strFile = Dir
Loop

End Sub

References:

1 Like