iLogic: BoM Emailer

I was looking through some of my site logs, and people have been searching for a way to email their BoM’s from Inventor. As I already have the iLogic code for sending emails, and for exporting BoM’s this was very easy to put together.

I added a small section that allows the user to choose a recipient from a list, making this a bit more useful.

The Animated GIF below shows how the utility works. Note that if nothing is selected, the rule exits, there is an option to choose “Someone Else”, and the email is then composed with blank entries.

Setup is very easy, simply create your users in the Array called oUser. Then assign an email address to each user. I’ve laid the code out to make this easy to do. Below is a simplified section of the code, to show what this looks like.

'-------------------------Add your users here
oUser.Add("Sally Sales")
oUser.Add("Mike Manager")
'-------------------------Add your users here

'--------------------------------Setup your email addresses here
If u1 = "Sally Sales" Then: o1 = "" :End If
If u1 = "Mike Manager" Then: o1 = "" :End If
'--------------------------------Setup your email addresses here

The Full iLogic utility is shown below, I have included links back to Curtis’ blog post which inspired the email component, and my original BoM export blog, should you wish to change the setup or export location of the BoM. This version exports out a “Structured, All Levels BoM”.

Here is the full code:

'Code by @ClintBrown3D 'Originally posted at
Dim oUser As New ArrayList
'-------------------------Add your users here
oUser.Add("Sally Sales")
oUser.Add("Mike Manager")
oUser.Add("Andy Admin")
oUser.Add("Donna Designer")
'-------------------------Add your users here
oUser.Add("Someone Else")
u1 = InputListBox("Choose an email receipient", oUser, oUser, Title := "Bom Emailer", ListName := "UNOFFICIAL INVENTOR")

'--------------------------------Setup your email addresses here
If u1 = "Sally Sales" Then: o1 = "" : End If
If u1 = "Mike Manager" Then: o1 = "" : End If
If u1 = "Andy Admin" Then: o1 = "" : End If
If u1 = "Donna Designer" Then : o1 = "" : End If
'--------------------------------Setup your email addresses here

If u1 = "" Then : Return: End If
If u1 = "Someone Else" Then : o1 = "" : u1 = "" :End If

'See original Bom Export code here:
oDoc = ThisDoc.ModelDocument
If oDoc.DocumentType = kPartDocumentObject Then
MessageBox.Show("You need to be in an Assembly to Export a BOM", "@u1 iLogic")
End If
oDoc = ThisApplication.ActiveDocument
oBOM = oDoc.ComponentDefinition.BOM

'You can change the output path by editing CSVpath below
'CSVpath = ("C:\Temp\") 'If you change the path, remember to keep a \ at the end
CSVpath = ThisDoc.Path + "\"

ClintsBoMExporter = "Structured - All Levels"
oBOM.StructuredViewFirstLevelOnly = False
oBOM.StructuredViewEnabled = True
Dim oStructuredBOMView As BOMView
oStructuredBOMView = oBOM.BOMViews.Item("Structured")
oStructuredBOMView.Export(CSVpath + ThisDoc.FileName(False) + ".xls", kMicrosoftExcelFormat)

'Create Email Contents
'Email code based on a post by Curtis:
oPerson = u1
oEmailAddress = o1
oOApp = CreateObject("Outlook.Application")
oOMail = oOApp.CreateItem(olMailItem)
oAdressee = "Hi " + oPerson & vbLf & vbLf & "Attached please find '"
oFileName = ThisDoc.FileName + "' Bill of Materials for review" & vbLf & vbLf & "Many Thanks"
oFrom = iProperties.Value("Summary", "Author")
With oOMail
.To = oEmailAddress
.Subject = "Please review " + ThisDoc.FileName + " Bill of Materials"
.Body = oAdressee + oFileName & vbLf & vbLf & oFrom
objOutlookAttach = .Attachments.Add((CSVpath + ThisDoc.FileName(False) + ".xls"))
End With

Comments are closed.

Create a website or blog at

Up ↑

%d bloggers like this: