- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
i made a iLogic rule to run my Outlook, and attach a PDF in a single e mail.
'------- Start of iLogic code -------------------
'Email Part of the Code adapted by Clint Brown @ClintCadline from Curtis Waguespack's blog
'http://inventortrenches.blogspot.co.uk/2011/04/using-inventor-ilogic-to-create-e-mail.html
'Ensure that this is a part file, exit on other files
oDoc = ThisDoc.ModelDocument
If oDoc.DocumentType = kPartDocumentObject
OType = 1
Else
OType = 0
End If
If OType = 0
MessageBox.Show("Email Code will only run on Part files", "Cadline")
Return
End If
'Roll up end of Part
ThisDoc.Document.ComponentDefinition.SetEndOfPartToTopOrBottom(True)
'Create Email Contents
oOApp = CreateObject("Outlook.Application")
oOMail = oOApp.CreateItem(olMailItem)
oAdressee = "Dear " + oPerson & vbLf & vbLf & "Attached please find '"
oFileName = ThisDoc.FileName + "' for review" & vbLf & vbLf & "Kind Regards"
oFrom = iProperties.Value("Summary", "Author")
'Create Email & Add Attachments
With oOMail
'.To = ajovicic@yahoo.com
.Subject = "Glas position " & AAA
.Body = "Hallo"
.attachments.Add ("C:\Users\user\Desktop\Neuer Ordner\Ablehnung der ZAV an Fieger am 29.01.2015.pdf")
.Display
End With
'------- end of iLogic code -------------------
.attachments.Add ("C:\Users\user\Desktop\Neuer Ordner\Ablehnung der ZAV an Fieger am 29.01.2015.pdf") - here is a example for arrach a single PDF file
But is it posible to attach all files in a folder in a single e mail. Withot the PathFile
Just like a Folder Path, and he attachs all PDFs or STPs in this folder
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Use a combination of a folder dialog and System.IO.Files.GetFiles(oFolderDialogresults, "*.pdf")
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization
iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread
Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects
Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help
Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
There is an some arrangement. I added the possibility to add an .dwg file with the use of an custom text parameter. When you run the code an arraylist will pop up with the option with person to contact. The email program used is Outlook.
'Messagebox open outlook. If incorrect program will crash. Question_1=MessageBox.Show("Is outlook open?", "DMF Automation",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question) If Question_1=vbNo Then Dim Proc As String = "Outlook.exe" Process.Start(Proc) End If If Question_1 = vbCancel Then Exit Sub End If 'Contact list Dim oUser As New ArrayList 'Contact list namelist 'Change "NAME" to your wanted contact name oUser.Add("NAME") oUser.Add("NAME") ' oUser.Add("") oUser.Add("Other") u1 = InputListBox("", oUser, oUser, Title := "Title", ListName := "Email exporter") 'Emailadres 'Put in the same contact name as before at the place "NAME" and email adres that at "EMAILADRES" If u1 = "NAME" Then : o1 = "EMAILADRES" : End If If u1 = "NAME" Then: o1 = "EMAILADRES" : End If If u1 = "" Then : Return: End If If u1 = "Other" Then : o1 = "" : u1 = "" :End If 'Run PDF code iLogicVb.RunRule("PDF") 'Create Email Contents oPerson = u1 oEmailAddress = o1 oOApp = CreateObject("Outlook.Application") oOMail = oOApp.CreateItem(olMailItem) oAdressee = "Dear " + oPerson & vbLf & vbLf & "You can see the drawings in the appendix. These relate to project:" + ThisDoc.FileName oFileName = vbLf & vbLf & "Best regrads," oFrom = iProperties.Value("Summary", "Author") With oOMail .To = oEmailAddress .Subject = "Project: " + ThisDoc.FileName .Body = oAdressee + oFileName & vbLf & vbLf & oFrom If PDF_mail="Ja" Then objOutlookAttach = .Attachments.Add(ThisDoc.Path + "\WT.pdf") End If If DWG_mail="Ja" Then objOutlookAttach = .Attachments.Add(ThisDoc.Path + "\" + ThisDoc.FileName + ".dwg") End If .Display End With
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I forgot to add the pdf converter that is used in this code. It will export the .pdf file to the folder of the active document. So here it is the code:
'Pdf exporter code to drawing folder (without arraylist) '-------------------------------------------------------------------- 'File location Dim ExportPath As String = ThisDoc.Path 'Check of het al bestaat If String.IsNullOrEmpty(ExportPath) Then MsgBox("De file bestaat niet!" _ & vbLf & "Sla de file eerst op",64, "Error message") Return End If 'Filename ExportFilename = ThisDoc.FileName(False)+".pdf" 'without extension '-------------------------------------------------------------------- 'Pdf settings (Not written by Michael Stienstra. Unfortunately source unknown) oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oDocument = ThisApplication.ActiveDocument oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium 'set PDF Options 'If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then oOptions.Value("All_Color_AS_Black") = 1 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 'oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintSheetRange 'End If '-------------------------------------------------------------------- 'File location oDataMedium.FileName = ExportPath & "\" & ExportFilename Try 'Create document oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) Catch 'Error respons message MessageBox.Show("An error has occurred", "Error") bError = True End Try