Create a .eml (email) file in Java

You can create eml files with the following code. It works fine with thunderbird and probably with other email clients: public static void createMessage(String to, String from, String subject, String body, List<File> attachments) { try { Message message = new MimeMessage(Session.getInstance(System.getProperties())); message.setFrom(new InternetAddress(from)); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to)); message.setSubject(subject); // create the message part MimeBodyPart content = new … Read more

MS Access VBA: Sending an email through Outlook [closed]

Add a reference to the Outlook object model in the Visual Basic editor. Then you can use the code below to send an email using outlook. Sub sendOutlookEmail() Dim oApp As Outlook.Application Dim oMail As MailItem Set oApp = CreateObject(“Outlook.application”) Set oMail = oApp.CreateItem(olMailItem) oMail.Body = “Body of the email” oMail.Subject = “Test Subject” oMail.To … Read more

Embedding image in email with VBA

Change your JPG file name to one word Example WF_Communications.jpg or WFCommunications.jpg .Attachments.Add “C:\Users\JoeSchmo\Pictures\WF_Communications.jpg”, olByValue, 0 .HTMLBody = “<BODY><IMG src=””cid:WF_Communications.jpg”” width=200> </BODY>”

Convert Early Binding VBA to Late Binding VBA : Excel to Outlook Contacts

To use Late binding, you should declare all your Outlook-specific objects as Object: Dim olApp As Object, olNamespace As Object, olFolder As Object, olConItems As Object Then: Set olApp = CreateObject(“Outlook.Application”) This will make each computer create the olApp object from the Outlook library that is installed on it. It avoids you to set an … Read more

Finding a workbook in one of multiple Excel instances

Try This Option Explicit Public Sub Example() Dim xlApp As Excel.Application Dim Book As Workbook Set xlApp = New Excel.Application Set Book = xlApp.Workbooks.Open(Environ( _ “USERPROFILE”) & “\Documents\Temp\Temp.xlsm”) ‘ Do something Set xlApp = Nothing Set Book = Nothing End Sub Or This which works for me. Option Explicit Public Sub Example() Dim xlApp As … Read more

Restrict Outlook Items by Date

You can find yesterday’s mail with two separate Restricts. Private Sub EmailYesterday() Dim oOlInb As Folder Dim oOlItm As Object Dim oOlResults As Object Dim i As Long Dim sFilter As String Dim sFilter2 As String Set oOlInb = Session.GetDefaultFolder(olFolderInbox) ‘Filter recent – Lower Bound of the range sFilter = “[ReceivedTime]>'” & format(Date – 1, … Read more