Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, i've this macro that get the selected file, collect it and open an email with this selected parts name in a body.
I wanna attach a pdf to this email but i don't find a solution.
All pdf is in
\\server-ut01\DISEGNI\PDF\and it's name is same as part name.
Example:
- Part name "SGE3000001.ipt"
- Pdf name "SGE3000001..pdf"
in a folder \\server-ut01\DISEGNI\PDF\
Can anyone help me? Thanks
Sub Main()
'Make a ref to active doc
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
'selected components collection
Dim oSelected As ObjectCollection
oSelected = ThisApplication.TransientObjects.CreateObjectCollection
Dim oCount As Integer
oCount = oDoc.SelectSet.Count
'Check that at least 1 is selected
If oCount = 0 Then
'MessageBox.Show("Please select a component.", "iLogic")
Exit Sub 'bail out
End If
'add to Object Collection
Dim i As Long
For i = 1 To oCount
If oDoc.SelectSet.Item(i).Type = _
ObjectTypeEnum.kComponentOccurrenceObject Then
oSelected.Add (oDoc.SelectSet.Item(i))
End If
Next
' Start Outlook.
' If it is already running, you'll use the same instance...
Dim oOApp
oOApp = CreateObject("Outlook.Application")
' Log on. Doesn't hurt if you are already running and logged on...
Dim olNs
olNs = oOApp.GetNamespace("MAPI")
olNs.Logon
For Each oItem In oSelected
oMsg = oMsg & vbLf & Left(oItem.Name, Len(oItem.Name) - 2)
Next
'send email using outlook
Dim oOMail
oOMail = oOApp.CreateItem(olMailItem)
With oOMail
'replace with your client's email address
.To = ""
.Subject = InputBox("Nome del cliente.", "iLogic", "") '"Please Review: "
.Body = "Particolari da produrre:" & vbLf & oMsg
' .Body = .Body & "Thanks, " & myName
.Display
For Each oMsg
objOutlookAttach = .Attachments.Add("\\server-ut01\DISEGNI\PDF\" & oMsg 6 ".pdf"(True))
Next
End With
End SubThe code for this operation is
For Each oMsg
objOutlookAttach = .Attachments.Add("\\server-ut01\DISEGNI\PDF\" & oMsg 6 ".pdf"(True))
Nextand obviously is incorrect. Can someone have idea to fix it?
Thanks
Danilo "DannyGi" G.
Mechanical design engineer and product developer
Mechanical design engineer and product developer
Solved! Go to Solution.

