I have a macro with which the user compile a document and then embed into an outlook message the link to the folder containing it; then, the message is saved as a draft and the macro ends.
The first problem is that the code gives ans error on .close command.
The second problem is that the user must be able to re-open that draft a first, a second, a third time and so on and add another hyperlink to the already existing everytime: I really don’t know ho to achieve this as every attempt ends with a deleting of the preivous message content.
Please, be kind with me and my code: my work and my studies are light years away from computer science and I do what I can.
Thanks a lot in advance.
`
Dim OApp As Object, OMail As Object, signature As String
Set OApp = CreateObject("Outlook.Application")
'Set OApp = GetObject("", "Outlook.Application")
'If OApp Is Nothing Then
'Set OApp = Application.CreateObject("Outlook.Application")
'End If
thisfile = "C:UsersXXXXDesktopYYYY.msg"
If Dir(thisfile) <> "" Then
GoTo line22 'draft exists
Else
GoTo LINE23 'draft not exists
End If
line22:
Set OMail = OApp.Session.OpenSharedItem(thisfile)
With OMail
.TO = AAAAA@BBBB
.BODYFORMAT = 2
.HTMLBody = "<A HREF="file:// & _
Application.ActiveDocument.path & _
""">Click Here</A>"
.Display
.SaveAs "C:UsersXXXXDesktopYYYY.msg", 3
.Close
End With
Set OMail = Nothing
Set OApp = Nothing
GoTo LINE24
LINE23:
Set OMail = OApp.CreateItem(0)
signature = OMail.body
With OMail
.TO = AAAA@BBBB
.HTMLBody = "<A HREF="file:// & _
Application.ActiveDocument.path & _
""">Click Here</A>"
.Display
.SaveAs "C:UsersXXXXDesktopYYYY.msg", 3
.Close
End With
Set OMail = Nothing
Set OApp = Nothing`
Emanuele Guidoni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.